Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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
Objective c iOS 6 UIInterfacePortrait ONLY viewcontroller正在呈现&;困在风景中。。。从导航堆栈中的横向viewcontroller返回时_Objective C_Xcode_Ios6_Uiinterfaceorientation_Autorotate - Fatal编程技术网

Objective c iOS 6 UIInterfacePortrait ONLY viewcontroller正在呈现&;困在风景中。。。从导航堆栈中的横向viewcontroller返回时

Objective c iOS 6 UIInterfacePortrait ONLY viewcontroller正在呈现&;困在风景中。。。从导航堆栈中的横向viewcontroller返回时,objective-c,xcode,ios6,uiinterfaceorientation,autorotate,Objective C,Xcode,Ios6,Uiinterfaceorientation,Autorotate,所以和其他很多人一样,我遇到了一个问题,在一个只有肖像的应用程序中,只有一个或两个ViewController同时支持纵向和横向界面方向。在iOS 6之前,一切正常,但突然自动旋转停止工作。由于这里有一些很好的问题,我通过让初始navController通过以下方式返回个人topViewController对shouldAutorotate的偏好,从而解决了这个问题: - (BOOL)shouldAutorotate { return self.topViewControlle

所以和其他很多人一样,我遇到了一个问题,在一个只有肖像的应用程序中,只有一个或两个ViewController同时支持纵向和横向界面方向。在iOS 6之前,一切正常,但突然自动旋转停止工作。由于这里有一些很好的问题,我通过让初始navController通过以下方式返回个人topViewController对shouldAutorotate的偏好,从而解决了这个问题:

    - (BOOL)shouldAutorotate
{
    return  self.topViewController.shouldAutorotate;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAll;
}
然而,我偶然发现了一个新问题。根vc(viewController A)不应自动旋转,而应仅支持纵向。导航堆栈中的ViewController B支持纵向和横向。如果我在viewController B中,并且在横向中,请触摸“后退”将视图弹出回viewController A。。。vc A在横向加载,它甚至不应该支持,并且不会旋转回纵向,因为vc A的shouldAutorotate设置为NO

任何关于如何处理这一问题的想法都将不胜感激。我最初的想法是用手动方法覆盖vc B的“后退”按钮,如果视图是横向的,第一个力将旋转回纵向。。。然后将viewcontroller弹出回vc A。。。但我不知道如何通过编程强制旋转。有什么想法吗

以下是vc A中的接口方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return NO;
}

-(BOOL)shouldAutorotate
{
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
以下是vc B中的内容:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

-(BOOL)shouldAutorotate
{
    return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return UIInterfaceOrientationPortrait;
}
在vcA集合中

-(BOOL)shouldAutorotate
{
  return YES;
}
但是保持

-(NSUInteger)supportedInterfaceOrientations
{
  return UIInterfaceOrientationPortrait;
}

然后,当您从vcB返回时,视图将旋转回(仅)支持的方向。问题是,所有容器视图控制器(选项卡栏控制器、导航控制器等)都支持您在plist文件中提供的所有接口方向。当系统请求支持的接口方向时,根视图控制器的设置和方法实现将覆盖它的子视图

在这种情况下,导航控制器支持横向和纵向,当B视图控制器弹出时,尽管系统要求A的界面方向,但它也会要求A的根视图控制器,这将是“赢家”,因为导航控制器支持横向,尽管只支持人像,但它仍保持在风景中


一种解决方案是,将根视图控制器子类化,并根据需要动态更改其旋转方法。当只需要portait时,root的实现应该只返回portait,当两个方向都可用时,root应该同时返回这两个方向。

完全相同的问题。一种解决方法是为
vc A
设置纵向状态栏方向,并使用
MakeRotation
手动旋转视图。它可以工作,但是当再次按下
vc B
时,我得到了一个错误的布局。有人知道是否有一种方法可以再次强制将
vcA
设置为纵向?是的,我也有同样的问题,但我没有将vcA设置为不旋转,因此当用户将设备设置为纵向时,视图会正确旋转。我没有找到任何可接受的解决方法。。。此外,苹果不同意要求用户旋转他们的设备……我在MPMoviePlayServiceWController上遇到了同样的问题,它必须保持所有的垂直方向,但应用程序的其余部分只是垂直方向。仍然找不到解决方案。丹尼尔,你的问题解决了吗?