2011-05-31 173 views
3

我有一个UITableViewController在纵向和横向都起作用。从此控制器,我将另一个视图控制器推到导航控制器上。这个新的viewController只是肖像。从横向推送视图控制器中的视图控制器

的问题是,当我在景观和推视图控制器的新视图 - 控制在景观以及直到我把它旋转为纵向。然后它应该是卡在肖像。

是否可以始终使其以纵向显示?即使它的父母在风景中推动它?

更新:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

回答

0

在你viewWillAppear:使用下面的代码:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait]; 
+0

@WrightCS谢谢,但只有旋转状态栏...其余的视图仍然在横向 – Linus 2011-05-31 19:08:37

+0

您的看法应该旋转任一方式。 '你在'shouldAutorotateToInterfaceOrientation'中有什么:'? – WrightsCS 2011-05-31 19:27:06

+0

@WrightCS我用这种方法更新了我的问题。 – Linus 2011-05-31 20:24:33

2

在viewWillAppear中:后状态栏的方向变化把这个:

//present/dismiss viewcontroller in order to activate rotating. 
UIViewController *mVC = [[[UIViewController alloc] init] autorelease]; 
[self presentModalViewController:mVC animated:NO]; 
[self dismissModalViewControllerAnimated:NO]; 

希望这将帮帮我!

附:在sdk上测试3.2.5 ios 5.0.1。

+0

这是更好的解决方案,我发现。 – 2012-11-14 14:40:05

+0

似乎不在iOS 6中工作 – maddog 2014-01-20 02:05:18

相关问题