still new to objective C and iOS i'm facing a new problem.
That's quite simple, i needed only one UIViewController in my app to be in landscape mode so i built my app this way :
One custom UINAvigationController : MyNavController set as "Is Initial View Controller" in my MainStoryBoard.storyboard. Then i add in this navController... :
- (NSUInteger)supportedInterfaceOrientations
{
return [[self topViewController] supportedInterfaceOrientations];
}
... to be able to control which UIVIewController childs of the custom nav controller can be in landscape orientation.
In the landscape UIVIewController i set :
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft ;
return UIInterfaceOrientationMaskPortrait;
}
so i can get this controller landscape or not. In this landscape controller in my nib (landscape.xib) i set a welcome view in UIPortrait mode and behind this view i had my landscape view. So when the user pushed the controller he sees that he has to turn his iPhone screen. I listen to orientation changing using :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification object:nil];
In orientationChanged i hide the portrait view and then we can see the landscape view.
It works, but when you rotate fast it works very bad, sometime the view is hidden sometimes not. So there is my questions :
- On a nav based app, what is the best way to make only one controller landscape capable ?
I use :
[self.navigationController pushNavigationController:landscapeController];
Is there a another way not to push the ladnscapeController so that it won't be navController dependant anymore ?
Thanls for all, any help will be welcome.