[英]iPhone interface orientation change not returning to portrait orientation
因此,我有一種看法,即在界面方向變為橫向時以模態形式呈現。 但是,當方向恢復為縱向並且模態視圖消失時,初始視圖的表視圖將保持橫向(此表視圖必須僅以縱向方向)
這是代碼:
- (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;
}
在您的AppDelegate中,您需要更改以下內容:
[self.window addSubview:viewController.view];
至
[self.window setRootViewController:viewController];
此外,如果要支持iOS的早期版本,請保留當前代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.