[英]iOS 9 View Not appearing
我注意到有一个uibutton在iOS 9中运行时未在我的应用程序中显示(在较早的OS版本中运行良好)。 我知道有些人注意到情节提要( https://forums.developer.apple.com/thread/14003 )也有类似的问题,尽管我没有使用这些,而是通过编程方式构建了视图。 无需担心自动布局或自动调整大小蒙版。
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(SUG_MARGIN, self.mainView.bounds.size.height - 40 - margin, self.mainView.bounds.size.width-margin*2, 40);
[button setTitle:NSLocalizedString(@"...", nil) forState:UIControlStateNormal];
button.titleLabel.font = //...;
button.backgroundColor = //...;
[self.mainView addSubview:button];
NSLog(@"main:%@\nadd:%@\nsuper:%@", NSStringFromCGRect(self.mainView.frame), NSStringFromCGRect(button.frame), button.superview);
nslog显示所有设置正确。
我在整个应用程序上都有类似的按钮,但这是唯一没有出现的按钮,这就是为什么我挠头。
重构后的代码仅在viewWillLayoutSubviews中分配度量框架,现在可以正常工作。 奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.