如何:iPad上的自动旋转和iPhone上的肖像?
嗨,我刚刚开始iPhone编程。我在Xcode 3.2中为iPad和iPhone创建了一个通用应用程序,evrerything运行良好。但现在我想在该应用程序中实现以下功能: 它应该在iPad上支持自动旋转,并且只能在iPhone上使用 我不知道怎么做 我有一个AppDelegate\u iPad委托文件, AppDelegate\u iPhone委托文件, 和“共享”选项卡下的viewcontroller,并由这两个代理共享 有什么办法可以实现这个功能吗。任何帮助都将不胜感激 谢谢 Vik在要实现此旋转行为的视图的视图控制器中,执行如何:iPad上的自动旋转和iPhone上的肖像?,iphone,ipad,xcode3.2,autorotate,universal,Iphone,Ipad,Xcode3.2,Autorotate,Universal,嗨,我刚刚开始iPhone编程。我在Xcode 3.2中为iPad和iPhone创建了一个通用应用程序,evrerything运行良好。但现在我想在该应用程序中实现以下功能: 它应该在iPad上支持自动旋转,并且只能在iPhone上使用 我不知道怎么做 我有一个AppDelegate\u iPad委托文件, AppDelegate\u iPhone委托文件, 和“共享”选项卡下的viewcontroller,并由这两个代理共享 有什么办法可以实现这个功能吗。任何帮助都将不胜感激 谢谢 Vik在要
shouldAutorotateToInterfaceOrientation
中的检查,如下所示:
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
UIDevice* thisDevice = [UIDevice currentDevice];
if (thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
return true;
}
else
{
return interfaceOrientation == UIDeviceOrientationPortrait;
}
}
运行iOS 6+的应用程序还需要实现ViewController的:
- (NSInteger)supportedInterfaceOrientations
和/或AppDelegate的:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
例如:
- (NSInteger)supportedInterfaceOrientations
{
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
return UIInterfaceOrientationMaskAll;
}
return UIInterfaceOrientationMaskPortrait;
}