I am migrating my apps over and on one I use a UIPickerView. In the viewDidLoad method I create the picker and set it’s y origin to be self.view.frame.size.height so that it is off screen. Then I just move it up when needed.
On the iPhone 5 self.view.frame.size.height is still returning 480 yet the UIView fills the screen correctly.
I’ve even tried using CGRectGetHeight(self.view.bounds) thinking that it may return something different…no dice. Any ideas as to why this maybe occurring.
That is because the size you selected in the view’s nib will be used until
viewWillAppear: (BOOL) animatedmethod. Then it will take the correct size.However you can use the following code to have the correct size since
viewDidLoadis called:STATUS_BAR_HEIGHTis 20 but it depends on your app. You may or may not need to add that line.EDIT
The problem with using
mainScreenbounds is that the frame doesn’t change on orientation change. That is the way it is designed. You can work it out with the following:CURRENT_ORIENTATIONis[[UIApplication sharedApplication] statusBarOrientation];