【发布时间】:2012-11-13 16:27:51
【问题描述】:
所以我有一个视图,当界面方向变为横向时,我会以模态方式呈现。但是,当方向返回纵向并且模态视图自行关闭时,初始视图中的表格视图仍保持横向(此表格视图必须仅纵向)
代码如下:
- (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
【问题讨论】:
-
那是关于 iOs6 的 .. 我需要在 iOs 5/6 iPhone 3gs/4/4s/5 上进行这项工作 ...
-
没什么好担心的,你也应该在 viewController 中保留
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation方法。
标签: iphone ios uiinterfaceorientation autorotate