0
votes

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!

1
how about [self layoutIfNeeded]?Larry Pickles

1 Answers

1
votes

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);
}