作者:卓菘碧625 | 来源:互联网 | 2023-01-20 13:50
iamgettingjsondataintouiwebview(whichisaddedthroughstoryboard)andifthejsondataisemp
i am getting json data into uiwebview(which is added through storyboard) and if the json data is empty i am adding a subview(which is added programatically).and in that subview i am adding a label.
我将json数据导入uiwebview(通过storyboard添加),如果json数据为空,我将添加子视图(通过编程添加)。在子视图中,我添加了一个标签。
when i run it i can see the subview and the label but its size is big, so it goes out of the subview. The code i have is
当我运行它时,我可以看到子视图和标签但是它的大小很大,所以它会离开子视图。我的代码是
var detailView = UIView(frame: CGRectMake(0, 143, 568, 376)) //Overlapping the UIWebview
//detailView.backgroundColor = UIColor.blackColor()
detailView.cOntentMode= UIViewContentMode.ScaleAspectFit
detailView.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth
self.view.addSubview(detailView)
var descLabel = UILabel(frame: CGRectMake(0, 0, 200, 200))
descLabel.textColor = UIColor.redColor()
descLabel.fOnt= UIFont(name:"HelveticaNeue;", size: 6.0)
descLabel.text = "No Description was found" +
" for \(self.strFullName)" +
" please try again later"
descLabel.textAlignment = NSTextAlignment.Center
descLabel.cOntentMode= UIViewContentMode.ScaleAspectFit
descLabel.autoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth
detailView.addSubview(descLabel)
When i run it on the simulator i see "No Description was fou..." and the rest of it is gone of the screen. as you can see from above code i have tried to set the font size, the font size does not change either, and also try to put it on different lines
当我在模拟器上运行它时,我看到“没有描述是fou…”,而其余的都不在屏幕上了。正如您从上面的代码中可以看到的,我尝试过设置字体大小,字体大小也没有改变,并且尝试将它放在不同的行上
What am i doing wrong which is causing the label to display like this? And how can i fix it.
我做错了什么导致标签像这样显示?我怎么才能修好它呢?
Thank you in advance for any help provided
预先感谢您提供的任何帮助
1 个解决方案