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 lik
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 to make sure that auto layout isn't activated in your storyboard file.
To turn it off, look at the inspector in interface builder. Click the icon that looks like a page all the way on the left. In the section "Interface Builder Document" uncheck "Use Auto Layout."
I find it's best to an entire view controller in IB with auto layout, or completely in code. Mixing the two can lead to weird behavior that is hard to debug.
There are several reasons why this might be happening. First of all, you need to make sure that your tableview isn't nil. If you're creating it programmatically, you need to be sure that you're calling alloc/init somewhere before you attempt to set the frame. If self.leftSideTableView
is an IBOutlet, this can be caused by forgetting to actually link the outlet to the interface object.
Then, second and less likely, you are creating the table view programmatically and initializing it properly, but you forgot to add it as a subview of one of your on screen views.
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:
.