我正在使用ios 6的新定位方法,它工作正常.我的视图以纵向模式呈现,当我呈现viewviewrnoller并将其旋转到横向时,忽略该视图控制器它还原方向.意味着它应该保留在风景中但它变成了肖像.这是我的代码.
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
return YES;
}
// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
我认为这是因为preferredInterfaceOrientationForPresentation方法,但没有得到解决方案.请帮助!
谢谢 !!
我使用游戏中心开发了IOS 5应用程序.现在我想让我的代码在IOS 6上运行.所以我让我的应用程序支持两种方向,即横向和纵向,这样当游戏中心登录屏幕弹出时它不会崩溃.但在那之后,我的家庭视图控制器不会在横向视图中启动.相反,当我进入另一个视图时,它会在横向打开,然后当我回来时,主视图将以横向打开.但是主视图第一次没有打开横向模式.
这是代码:
- (BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
Run Code Online (Sandbox Code Playgroud)
这些是我在IOS 6的主视图中使用的代理.
我在我的应用程序中使用UINavigationController,我的第一个控制器叫做A,它只对portrite有严格要求,我的A控制器中有一个按钮.一旦我点击按钮,我就会在另一个名为B的视图控制器上创建实例.在为BI创建实例后,使用以下方法进行模态呈现
[self presentViewController:BInstance animated:YES completion:^{
NSLog(@"completed");
}];
Run Code Online (Sandbox Code Playgroud)
我的B控制器能够支持所有方向,这是预期的,直到ios5.1及更早版本.现在我正在尝试使用Xcode4.5在ios6上运行我的项目它没有被轮换我期待解决这个问题我发现了一些关于shouldAutorotateToInterfaceOrientation 的博客:方法从最新的ios6中被弃用了.我也用过替代品
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
Run Code Online (Sandbox Code Playgroud)
但仍然没有太多预期的结果.
问题:什么使我的B控制器适用于所有方向,即使我的父A只适用于portrite.
在此先感谢您对此有用的所有建议/建议.