我已经将我的 Xcode 更新到 4.5 ,我已经实现了如下方向方法
-(BOOL)shouldAutorotate{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
我正在 willRotateToInterfaceOrientation 方法中设置按钮、标签、图像的框架大小
-(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 文件 - 没问题。
Apple 不会在 IOS 6.0 中调用 shouldAutorotatetoInterfaceOrientation 调用,除非您告诉主窗口将其发送到哪个视图控制器。
通过将 window.rootViewController 设置为我的应用程序的顶级视图控制器,我可以在我的应用程序中进行旋转
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
window.rootViewController = topLevelViewController;
...
}
我的应用程序的 iPhone 版本仅支持两个纵向方向,因此我的顶级 iPhone 视图控制器需要一种新方法:
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait |
UIInterfaceOrientationMaskPortraitUpsideDown;
}
这是关于嗡嗡声触摸.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)