所以我有一个 UITableViewControler 以纵向模式显示一个表格视图。
一旦我旋转 iPhone,我想以横向模式呈现模式视图。
在我使用的 tableView 中:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
并处理当前的模态视图:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration {
if((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft))
{
NSLog(@"Push page view");
PagingViewController *s = [[PagingViewController alloc] initWithNibName:@"PagingView" bundle:nil];
s.hidesBottomBarWhenPushed = YES;
[self presentModalViewController:s animated:YES];
[s release];
}
}
模态视图我有以下内容:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
为了消除模态视图本身,我这样做:
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration {
if (interfaceOrientation == UIInterfaceOrientationPortrait)
{
NSLog(@"Dismiss my self");
[self.parentViewController dismissModalViewControllerAnimated:YES];
}
}
一些这是如何工作的两次。我第三次将 iPhone 从纵向模式旋转到横向模式时,我遇到了错误的访问错误。
我无法弄清楚是什么给了我错误。有人在乎打吗?