Search code examples
ioscocoa-touchios7

Setting the frame of an UIView does not work


I have a problem with the frame-property in iOS 7. I wanna resize some UIViews in the viewDidLoad-method of my UIViewController, but if I do it like int screenHeight = [[UIScreen mainScreen] bounds].size.height; [self.leftSideTableView setFrame: CGRectMake(0, 0, 320, screenHeight)]; the height is set as I want it till the end of the method, but in every other method it is as is has been before!

What's wrong with it or is it just a bug of the compiler or anything else?


Solution

  • One has to put view resizing into -viewDidLayoutSubviews:! (documentation)

    Placing view frame changes into -viewWillAppear: or -viewDidLoad: will not work, because the views are not laying out yet!