I am currently working on a project and I need to support both portrait and landscape orientation. I have read several books, and all of them tell me to do different things. The view I want to support landscape orientation is simple. It is a UINavigationBar and a UIWebview which is attached to the viewcontrollers view. I have made the view programatically.
Is it correct that I use this method:
– (void)willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;
I have seen that prior to iOS 3 there was two other methods that were invoked. However I do not target my app below iOS 3.
This code is working but my question is if it is the correct way of doing it programmatically because I don’t want to use the InterfaceBuilder on this view.
Codesnippet (working)
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)x duration:(NSTimeInterval)duration {
if (UIInterfaceOrientationIsLandscape(x)) {
topbar.frame = CGRectMake(0.0f, 0.0f, 480.0f, 44.0f);
}
}
And is it correct that I don’t need to apply any animation, iOS will handle this right?
You can use the below two methods to support interface orientations
Yes you do not have to worry about the animation part,the OS will take care of it.