我找到了许多与我的问题相关的答案,但没人能帮助我解决我的问题。
正如我的标题所说,状态栏方向在iOS 6中没有变化。我为更改状态栏方向编写了正确的代码,但它对我不起作用。它不适用于iOS模拟器和放大器设备(iPad)。
在我的rootviewcontroller中,我使用UIInterfaceOrientationMaskAll实现了与bellow代码相同的功能,之后,我使用presentModelViewController来启用子视图控制器,但在子视图控制器中我无法更改状态栏方向。
我也实施了
-(NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskAll;
}
在AppDelegate中。
我的代码是:
-(BOOL) shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}
请帮我解决这个问题。
答案 0 :(得分:3)
你需要回答NO
rootViewController中的shouldrotate方法才能正常工作。
查看文档
讨论此属性的值是一个表示a的常量 接收者状态栏的方向。请参见UIInterfaceOrientation 详情。设置此属性会将状态栏旋转到 指定方向而不设置过渡动画。如果你的 应用程序具有可旋转的窗口内容,但是,您不应该 使用此方法任意设置状态栏方向。的的 如果是,则此方法设置的状态栏方向不会更改 设备更改方向。有关可旋转窗口视图的更多信息,请参阅 适用于iOS的View Controller编程指南。