我有一个名为:MainController的UIViewController实例。在这个MainController.view中我有另一个视图(使用名为SlideViewContent的类)谁有一个nib实例:
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"SlideMenuView"
owner:self
options:nil];
self.bottomSlideMenu = [nibContents objectAtIndex:0];
self.bottomSlideMenu.frame = CGRectMake(0,0,screenWidth,screenHeight);
self.bottomSlideMenu.bounds = CGRectMake(0,0,screenWidth,screenHeight);
所有Autolayout约束都已添加到nibFile中,并且没有任何警告就可以正常工作。我想对此应用autolayout并调用这些方法来刷新具有良好屏幕尺寸的UI:
[self setNeedsDisplay] or [self setNeedsLayout];
但没有什么可行的!
答案 0 :(得分:1)
无需实现[self setNeedsDisplay]或[self setNeedsLayout];
只需实现layoutSubviews并设置视图的框架。
- (void)layoutSubviews
{
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;
self.bottomSlideMenu.frame = CGRectMake(0,0,screenWidth,screenHeight);
}