Reputation: 235
I have two views in my application. One (by default) is Landscape. When the user clicks a certain menu, i need a Portrait view to appear.
I have all the code in place and i'm trying to use this:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
But the app still displays the next view in Landscape. I can't figure this out. Any help will be great.
Upvotes: 1
Views: 396
Reputation: 5886
You can use following code in your viewWillAppear
method to make your view portrait.
[[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(id)UIInterfaceOrientationPortrait];
Upvotes: 0
Reputation: 2163
You can not do it using navigation controller but if you are presenting your view then it is possible to do that and make sure when you are presenting your view animation should be NO.
It works for me very well.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Upvotes: 1