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?
Frame A view's frame ( CGRect ) is the position of its rectangle in the superview 's coordinate system. By default it starts at the top left. Bounds A view's bounds ( CGRect ) expresses a view rectangle in its own coordinate system.
1) Control-drag from a frame view (e.g. questionFrame) to main View, in the pop-up select "Equal heights". 2)Then go to size inspector of the frame, click edit "Equal height to Superview" constraint, set the multiplier to 0.7 and hit return.
The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.
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!
Check if you are using autolayout
in your xib file. If you don't want to use autolayout
, uncheck it in your xib file.
Change your self.leftSideTableView
frame in -viewWillAppear:
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With