[英]present modal view on rotate
因此,我有一個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從縱向模式旋轉到橫向模式時,出現訪問錯誤。
我不知道是什么給了我錯誤。 有人在乎嗎?
我能想到的最簡單的方法是實現-shouldAutorotate ...並關閉模態視圖,並返回NO以中止旋轉。 也許這足以避免任何並發問題。 如果您不喜歡這個建議,請查看NSNotificationCenter。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.