0

我有另一个方向问题。但是这个非常棘手。 我的RootViewController是一个正常的NavigationController。方向风景 - >人像不工作

self.window.rootViewController = _naviController; 

里面有另一个ViewController,我们称之为VC1。 VC1有一些按钮和标签。它就像文件夹的概述。

如果我按下一个按钮,我来与3视图控制器(页)下一个视图控制器和按钮的另一一束(如文件夹内看图片/内缩略图):

Archiv *archiv = [[Archiv alloc] init]; 
[self.navigationController pushViewController:archiv animated:YES]; 
[archiv release]; 
中的loadView

firstPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 0, 768, 960)]; 
[firstPage setRootViewController:self]; 
secondPage = [[Page alloc] initViewWithFrame:CGRectMake(0, -960, 768, 960)]; 
[secondPage setRootViewController:self]; 
thirdPage = [[Page alloc] initViewWithFrame:CGRectMake(0, 960, 768, 960)]; 
[thirdPage setRootViewController:self]; 

如果我现在上的按钮再次点击活动页面推我的第三个视图控制器(带图像缩放,拖动......):

Picture *pic = [[Picture alloc] initWithPicURLString:urlString]; 
[rootViewController.navigationController pushViewController:pic animated:YES]; 
[pic release]; 

使用NavigationController的BackButton,我总是可以回到以前的视图。

一些更多的信息:

现在棘手的问题:

如果我从第2个VC切换到第3 VC,还有来自纵向更改方向为横向,按后退按钮一切工作shouldAutorotateToInterfaceOrientation呼吁,帧大小和起源改变...)。 ,如果我周围做它的其他方式,我在风景模式,从第2个VC切换到第3 VC,旋转为纵向,回来第2个VC与后退按钮的状态 - 和controllerBar是在顶部但是shouldAutorotateToInterfaceOrientation未被称为

请帮帮我。 $ h @ rky

回答

1

试试这个,它为我工作:

-(void)viewWillAppear:(BOOL)animated 
{ 
    [super viewWillAppear:animated]; 
    [self shouldAutorotateToInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation] ]; 
} 
+0

是的,这项工作也是,但这不能回答问题为什么当我回到纵向方向时视图没有调用。无论如何,如果nodoby告诉我为什么这会在下周发生,我会接受答案。 – Sharky

+0

就像我承诺的接受和upvote,因为决议比我的方式xD更聪明。 $ H @ RKY – Sharky

0

今天我得到了解决问题而不知道原因的想法。 在我的第三个VC中,我创建了一个指向第二个视图的指针,并且自己调用了shouldAutorotateToInterfaceOrientation

但是问题仍然是一样的:为什么shouldAutorotateToInterfaceOrientation没有在描述的情况下调用?

亲切的问候。$ H @ RKY

0

shouldAutorotateToInterfaceOrientation只有当用户转动叫,所以当你从横向到纵向或以其他方式再查看控制器仍然景观,所以这个解决问题,你必须破解的代码,它的意思是,当你推查看从横向控制器为纵向presentViewController例如:

ListCurrentViewController *list = [self.storyboard 
    instantiateViewControllerWithIdentifier:@"ListCurrentViewController"]; 
       [self.navigationController presentViewController:list animated:NO completion:Nil]; 
       [list dismissViewControllerAnimated:NO completion:Nil]; 
       [self.navigationController pushViewController:list animated:YES]; 
在ListViewController功能

称为:

(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation // iOS 6 autorotation fix { return UIInterfaceOrientationPortrait; } 

,你必须为UINavigationController的

(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return [self.visibleViewController preferredInterfaceOrientationForPresentation]; 
} 

我希望这个解决将帮助您创建类别。