Xcode 4.5 iOS 6.0模拟器定向不起作用 [英] Xcode 4.5 iOS 6.0 simulator orientation not working

查看:97
本文介绍了Xcode 4.5 iOS 6.0模拟器定向不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Xcode更新为4.5,并实现了以下定位方法

I have updated my Xcode to 4.5 , I have implemented the orientation methods as below

  -(BOOL)shouldAutorotate{

    return YES;

  }

-(NSUInteger)supportedInterfaceOrientations{

    return UIInterfaceOrientationMaskAll;
}

我将在willRotateToInterfaceOrientation方法中设置按钮,标签,图像的帧大小

I am setting the frame sizes of buttons ,labels,images in willRotateToInterfaceOrientation method

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{


  if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait )||
        ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown ))
  {

    // set frame sizes for portait

   }

  else if(( [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft )||
            ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight ))

  {

    // set frame sizes for landscape

   }

}

,但是有时在旋转模拟器时不会调用此方法,并且 有时模拟器从另一个viewController导航时未检测到方向.我已经检查了info.plist文件-很好.

but sometimes this method is not getting called when rotating the simulator and sometimes the simulator is not detecting orientation when navigating from another viewController . I have checked info.plist file - it is fine.

推荐答案

除非您告诉主窗口哪个视图控制器将其发送到Apple,否则苹果不会在IOS 6.0中调用shouldAutorotatetoInterfaceOrientation调用.

Apple does not call the shouldAutorotatetoInterfaceOrientation call in IOS 6.0 unless you tell the main window which view controller to send it to.

通过在

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
   ...
   window.rootViewController = topLevelViewController;
   ...
}

我的应用程序的iPhone版本仅支持两种纵向显示,因此我的顶级iPhone视图控制器需要一种新方法:

The iPhone version of my app only supports the two portrait orientations, so my top iPhone view controller required a new method:

- (NSUInteger)supportedInterfaceOrientations 
{
  return  UIInterfaceOrientationMaskPortrait |  
          UIInterfaceOrientationMaskPortraitUpsideDown;
}

这是有关 Buzz Touch 的讨论.

这篇关于Xcode 4.5 iOS 6.0模拟器定向不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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