Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.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
Iphone 通用应用程序中的iOS 6.0定位问题_Iphone_Ios_Objective C_Ipad_Uiinterfaceorientation - Fatal编程技术网

Iphone 通用应用程序中的iOS 6.0定位问题

Iphone 通用应用程序中的iOS 6.0定位问题,iphone,ios,objective-c,ipad,uiinterfaceorientation,Iphone,Ios,Objective C,Ipad,Uiinterfaceorientation,我有一个应用程序,它有一个UIViewController作为根视图控制器(不是TabBar或NavigationControllerapp!)。这个应用程序是通用的。它应该永远是iPhone的肖像,永远是iPad的风景 我尝试了以下方法,但我认为这是iOS 5代码,因为它在iOS 6中没有被调用: - (BOOL)shouldAutorotate { return YES; } - (BOOL)shouldAutorotateToInterfaceOrientation:(U

我有一个应用程序,它有一个
UIViewController
作为根视图控制器(不是
TabBar
NavigationController
app!)。这个应用程序是通用的。它应该永远是iPhone的肖像,永远是iPad的风景

我尝试了以下方法,但我认为这是iOS 5代码,因为它在iOS 6中没有被调用:

    - (BOOL)shouldAutorotate
{
    return YES;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    else
    {
        return (interfaceOrientation == (UIInterfaceOrientationLandscapeLeft | UIInterfaceOrientationLandscapeRight));
    }
}

感谢您的帮助

以下是iOS 6的一组代码。它使用面具。如果是针对整个iPhone一个方向和iPad一个方向,那么在项目级别,您可以通过取消选择与您不想要的方向相关的按钮进行设置。也就是说,如果iPhone中的所有视图都是相同的,那么iPad也适用。如果要使用代码执行此操作,请执行以下操作:

- (BOOL) shouldAutorotate
{
return YES;
}

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

把你不想用的方向拿出来。如果您需要更多帮助,请告诉我。

请阅读
UIViewController
的文档。方向更改处理与iOS 6不同。这些文件涵盖了这些变化。关于这个话题还有很多现存的问题。它实际上是一个混合体:D应该是ios6,其他IOS5使用的是xib或故事板?@CodeMonkey:我使用的是xib。很抱歉,如果以前有人问过这个问题,我查阅了有关堆栈溢出的文档和许多答案,但是我没有在这个特定场景中实现我想要的。没关系,我也做了同样的事情。有时候你只是厌倦了看医生的书。检查我的答案,让我知道它是否有效。谢谢!为了使它适用于我的情况,我稍微修改了代码:
-(BOOL)shouldAutorotate{return YES;}-(NSUInteger)supportedInterfaceOrientations{if(UI\u USER\u INTERFACE\u IDIOM()==UIUserInterfaceIdiomPhone){return UIInterfaceOrientationMaskPortrait;}返回UIInterfaceOrientationMaskLandscape;}
很高兴能提供帮助。快乐编码:)