ios 6定位方法 [英] ios 6 orientation methods

查看:86
本文介绍了ios 6定位方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS 6中的方向方法已经改变。
我在纵向模式下的整个应用程序有很多视图控制器(不是标签栏视图控制器)我只想将我的一个视图控制器旋转到横向模式(它实际上是当我旋转设备时显示webView。下面的方法在xcode 4.4中工作但是,它不在Xcode.4.5中。

the orientation methods have changed in iOS 6. my whole app in portrait mode got to many view controllers (not tab bar view controllers) i just want to rotate one of my view controller to landscape mode (it actually displays a webView) when i rotate the device.the below method was working in xcode 4.4 but, it's not in Xcode.4.5

- (BOOL)shouldAutorotateToInterfaceOrientation:
  (UIInterfaceOrientation)interfaceOrientation {
  return (interfaceOrientation == UIInterfaceOrientationPortrait ||
 interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
interfaceOrientation == UIInterfaceOrientationLandscapeRight );

上述方法在xcode 4.5中不起作用,因为我改变了下面的方法但是虽然它不起作用....请提出任何建议。

the above method won't work in xcode 4.5 for this reason i have changed the below method but even though its not working....plz any suggestions thanks.

 - (BOOL) shouldAutorotate{
 [[UIApplication sharedApplication] setStatusBarOrientation:           UIInterfaceOrientationPortrait];
  return self.modalViewController.shouldAutorotate;
}
 -(NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationMaskLandscape;
}


推荐答案

您是否使用标签栏视图控制器?如果您使用它,那么即使您只想旋转一个,所有选项卡中的所有视图控制器都应该能够旋转。

Do you use tab bar view controller? If you use it, then all view controllers in all tabs should be able to rotate even if you only want to rotate only one.

-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

这在iOS6中应该可以正常工作。

This should work fine in iOS6.

如果使用UINavigationViewController,则会调用其方法。还有另一个解决方案。

If you use UINavigationViewController, then its methods would be called. There is another solution.

// App delegate.m
- (NSUInteger)application:(UIApplication *)application    supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    NSUInteger orientations = UIInterfaceOrientationMaskAllButUpsideDown;

    if(self.window.rootViewController){
        UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
        orientations = [presentedViewController supportedInterfaceOrientations];
    }

    return orientations;
}

然后在视图控制器中

- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskPortrait;
}

这篇关于ios 6定位方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆