iPhone界面方向更改不返回纵向方向

iPhone界面方向更改不返回纵向方向,iphone,ios,uiinterfaceorientation,autorotate,Iphone,Ios,Uiinterfaceorientation,Autorotate,所以我有一个观点,当界面方向改变为横向时,我以模态的方式呈现。但是,当方向返回到“纵向”且“模式视图”自行解除时,初始视图中的表视图仍保持横向(此表视图必须仅为“纵向”) 代码如下: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return ((interfaceOrientation == UIInterfaceOrientationPortr

所以我有一个观点,当界面方向改变为横向时,我以模态的方式呈现。但是,当方向返回到“纵向”且“模式视图”自行解除时,初始视图中的表视图仍保持横向(此表视图必须仅为“纵向”)

代码如下:

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

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if ((toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)) {
        [self performSegueWithIdentifier:@"showCatChart" sender:self];
    }
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
        [self refreshTableView];
    }
}
我试图刷新tableview,但这不会使它再次出现。。。 这可能是从视图层次。。。
NavigationController->tableView(仅纵向)->tableView->landscapeViewModalController

在appdelegate中使用以下命令

[self.window addsubview:viewcontroller];

仅此一项就可以解决您的定位问题。

对于iOS 6,您需要实现以下功能:

- (BOOL)shouldAutoRotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
[self.window addSubview:viewController.view];
在AppDelegate中,您需要更改以下内容:

- (BOOL)shouldAutoRotate {
    return YES;
}

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
[self.window addSubview:viewController.view];


另外,如果您想支持iOS的早期版本,请保留当前代码。

您应该了解有关iOS 6的信息。。我需要在iOs 5/6 iPhone 3gs/4/4s/5上完成这项工作…没什么好担心的,伙计,你应该在你的viewController中保留
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
方法。viewController应该是什么?初始navigationController?是,n将该navigationController用作[self.window addsubview:navigationController.view];不起作用。。。同样的问题。。。视图返回到纵向模式,但其中的显示看起来像在横向中。。。