Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何:iPad上的自动旋转和iPhone上的肖像?_Iphone_Ipad_Xcode3.2_Autorotate_Universal - Fatal编程技术网

如何:iPad上的自动旋转和iPhone上的肖像?

如何: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在要

嗨,我刚刚开始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;
}