I am currently creating an app which contains a pickerView and a tapbar within a view. The view is placed on the bottom of the screen. The tapbar is always visible. If I tap a button on the tapbar, the view will move up and show the pickerView. My Problem is:
The view does not move down to the bottom of the iPhone 5 screen. I placed this code in different locations:
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (screenSize.height > 480.0f){
[UIView beginAnimations:Nil context:Nil];//tells the compiler to start a new animation
[UIView setAnimationDuration:0.6];//in seconds
self.hiddenView.frame = CGRectMake(0, 504, 320, 260);//move the picker to a specific position (504 = 568 - statusbar(20) - tapbar(44))
[UIView commitAnimations];//tells the compiler to start the animations
}
such as in the:
-(void)viewDidLoad{}
-(void)viedWillAppear{}
-(void)viewDidAppear{}
I am clueless. Does anyone know how to make it the right way?
UPADTE
Ok thanks for all the answers, but my animation works fine. My problem is that it is executed every time (checked using breakpoints) won't fire (the view won't move down). So I asked WHERE I have to put my code in order to work properly. Not if the code was correct, because it is. I know there are different ways to check if it is an iPhone 5 and to animate things, but again: this code is working and not the actual problem. I hope you understand my problem better now.
Ok since apparently nobody correctly understood my question (or didn't actually read it to the end?), I had to find an answer for myself. If somebody encounters the same problem here is how I solved it.
Just place your code into the -(void)viewDidLayoutSubviews{}
function. It will execute as soon as the view is fully loaded.
-(void)viewDidLayoutSubviews{
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
if (screenSize.height > 480.0f){
[UIView beginAnimations:Nil context:Nil];//tells the compiler to start a new animation
[UIView setAnimationDuration:0.0];//in seconds
self.hiddenView.frame = CGRectMake(0, 504, 320, 260);//move the picker to a specific position
[UIView commitAnimations];//tells the compiler to start the animations
}
}