ios6中的方向问题 [英] orientation issue in ios6
问题描述
我在我的应用程序中使用UINavigationController,我的第一个控制器名为 A ,只有portrite是严格的,我的 A 控制器中有一个按钮。我点击在按钮上,我正在为另一个名为 B 的视图控制器创建实例。在为BI创建实例后,使用以下方法进行模态显示
I am using UINavigationController in my application and my first controller called A and it is strict to portrite only and there is a button in my A controller.Once I click on the button I am creating instance to the another view controller called B. After creating the instance for B I am presenting modally using below method
[self presentViewController:BInstance animated:YES completion:^{
NSLog(@"completed");
}];
我的B控制器能够支持所有方向,这是预期的,直到ios5.1和早期版本。现在我正在尝试使用Xcode4.5在ios6上运行我的项目它没有被轮换我期待解决这个问题我发现一些关于 shouldAutorotateToInterfaceOrientation:方法的博客从最新版本中被弃用了iOS6的。我也使用了替代方案
My B controller can able will support all the orientations, this is expected, till the ios5.1 and earlier versions. Now I am trying to run my project on the ios6 using Xcode4.5 it is not getting rotated I am looking forward to solve the issue I found some of the blogs about shouldAutorotateToInterfaceOrientation: method got deprecated from the latest ios6. I used alternative also
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
但预期结果仍然不多。
问题:即使我的父 A 仅适用于portrite,我的 B 控制器将适用于所有方向。
Question: What makes my B controller will work for all orientations even my Parent A works only for portrite.
在此先感谢您对此有用的所有建议/建议。
Thanks In advance All your suggestions/advice useful on this.
推荐答案
首先,在AppDelegate中,写下这个。 这非常重要
First of all, in AppDelegate, write this. THIS IS VERY IMP
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return (UIInterfaceOrientationMaskAll);
}
然后,对于UIViewControllers,你只需要 PORTRAIT 模式,写下这些函数
Then, For UIViewControllers, in which you need only PORTRAIT mode, write these functions
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait);
}
对于需要 LANDSCAPE 的UIViewControllers,请更改屏蔽全部。
For UIViewControllers, which require LANDSCAPE too, change masking to All.
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskAllButUpsideDown);
//OR return (UIInterfaceOrientationMaskAll);
}
现在,如果你想在Orientation改变时做一些改变,那么使用这个函数。
Now, if you want to do some changes when Orientation changes, then use this function.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}
这篇关于ios6中的方向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!