Reputation: 11
I have a UIViewController instance named: MainController. within this MainController.view I have another view (with class named SlideViewContent) who is have a nib instance:
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);
All Autolayout constraints has been added to the nibFile and works fine with no warnings. I would like to apply autolayout on this and call these methods to refresh UI with the good screen size:
[self setNeedsDisplay] or [self setNeedsLayout];
But nothing would work!
Upvotes: 0
Views: 48
Reputation: 11
No need to implement neither [self setNeedsDisplay] or [self setNeedsLayout];
Just implement layoutSubviews and set the frame of the views.
- (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);
}
Upvotes: 1