当我从nil文件启动时,IOS自动旋转

时间:2013-09-11 02:38:26

标签: ios

我设置了我的应用仅支持横向。如果iPad模拟器设备OrientationLandscapeRight,当我从nib文件启动我的应用程序时,它将从UIInterfaceOrientationLandscapeRight快速自动旋转到UIInterfaceOrientationLandscapeLeft。但是如果iPad模拟器OrientationLandscapeLeft或应用程序中的代码:didFinishLaunchingWithOptions: 没有任何事情发生。

-(void)application:(UIApplication *)application didChangeStatusBarOrientation:(UIInterfaceOrientation)oldStatusBarOrientation{           
   NSLog(@"%d%d%d%d",UIInterfaceOrientationPortrait
                    ,UIInterfaceOrientationPortraitUpsideDown
                    ,UIInterfaceOrientationLandscapeLeft
                    ,UIInterfaceOrientationLandscapeRight);
   NSLog(@"%d",oldStatusBarOrientation);}

从nib文件启动的日志:

2013-09-11 11:12:33.235 Wenxianji [925:15203] 1243

2013-09-11 11:12:33.238 Wenxianji [925:15203] 1

2013-09-11 11:12:33.251 Wenxianji [925:15203] 1243

2013-09-11 11:12:33.253 Wenxianji [925:15203] 3

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
      self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
      self.window.backgroundColor = [UIColor whiteColor];

     _spvc   = [[MySplitViewController alloc] init];
     _master = [[MasterViewController alloc] init];
     _detail = [[DetailViewController alloc] init];

     _spvc.delegate = _detail;
     _spvc.viewControllers = @[_master, _detail];

     _master.detailViewController = _detail;

     [self.window setRootViewController:_spvc];
     [self.window makeKeyAndVisible];
      return YES;}

程序时的日志:

2013-09-11 11:26:34.757 Wenxianji [960:15203] 1243

2013-09-11 11:26:34.760 Wenxianji [960:15203] 1

1 个答案:

答案 0 :(得分:0)

 -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

 // enables only landscapeLeft and landscapeRight orientations

 return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

1.在每个需要设置其方向的viewController中使用此函数。

2.为支持的方向调整plist。

3.在项目中调整支持的方向 - >目标 - >摘要 - > iphone / ipad部署信息。

4.在属性检查器中调整视图的方向(例如,根视图)。

通知问题是否仍然存在。