我有以下情况:
从appDelegate我做:
firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController *firstNavController = [[UINavigationController alloc]initWithRootViewController:firstViewController];
firstViewController-只需要处于纵向模式
为了做到这一点,我做了:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
从firstViewController
我的角度出发,我正在推动另一个需要同时具有纵向和横向功能的视图控制器。
secondViewController
预期的行为-在肖像和风景模式下
我也对firstViewController遇到了问题,尽管我将其限制为纵向模式,但该视图也以横向模式显示。我究竟做错了什么?
在项目中使用以下方法添加UINavigationController类别
#import "UINavigationController+MyNavigation.h"
@implementation UINavigationController (MyNavigation)
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
这解决了我的问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句