Iphone 基于导航的应用程序:仅一个横向UIVIewController
对于目标C和iOS来说还是新的,我面临着一个新问题 这很简单,我的应用程序中只需要一个UIViewController就可以处于横向模式,因此我以这种方式构建了我的应用程序: 一个自定义UINAvigationController:MyNavController在my MainstryBoard.storyboard中设置为“是初始视图控制器”。然后我加上这个导航控制器…:Iphone 基于导航的应用程序:仅一个横向UIVIewController,iphone,ios,objective-c,uiviewcontroller,orientation,Iphone,Ios,Objective C,Uiviewcontroller,Orientation,对于目标C和iOS来说还是新的,我面临着一个新问题 这很简单,我的应用程序中只需要一个UIViewController就可以处于横向模式,因此我以这种方式构建了我的应用程序: 一个自定义UINAvigationController:MyNavController在my MainstryBoard.storyboard中设置为“是初始视图控制器”。然后我加上这个导航控制器…: - (NSUInteger)supportedInterfaceOrientations { return [[
- (NSUInteger)supportedInterfaceOrientations
{
return [[self topViewController] supportedInterfaceOrientations];
}
。。。能够控制自定义导航控制器的哪个UIVIewController子项可以是横向的
在我设置的横向UIVIewController中:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft ;
return UIInterfaceOrientationMaskPortrait;
}
所以我可以得到这个控制器的景观或没有。
在我的nib(landscape.xib)中的这个横向控制器中,我在UI纵向模式下设置了一个欢迎视图,在这个视图后面有我的横向视图。因此,当用户按下控制器时,他看到他必须打开iPhone屏幕。我通过以下方式收听方向改变:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged) name:UIDeviceOrientationDidChangeNotification object:nil];
在方向更改中,我隐藏了纵向视图,然后我们可以看到横向视图
它可以工作,但当你快速旋转时,效果非常糟糕,有时视图被隐藏,有时则不被隐藏。所以我的问题是:
- 在基于导航的应用程序上,什么是使一个控制器只具备横向功能的最佳方法
- 我使用: [self.navigationController推送navigationController:landscapeController]
对所有人来说,任何帮助都是欢迎的 在推送下一个控制器之前使用此代码
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait);
当弹出到后台控制器时使用此代码
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationIsPortrait(UIInterfaceOrientationMaskPortrait);
我在我的应用程序中使用此代码只有一个页面是横向模式