问题描述
||
我有一个UITableViewController在纵向和横向均可使用。从这个控制器,我将另一个视图控制器推到导航控制器上。这个新的viewController仅是纵向的。
问题是当我在风景中并推动视图控制器时,新的viewcontroller也在风景中,直到我将其旋转为纵向。然后按原样卡在肖像中。
是否可以始终使它以纵向显示?即使其父公司将其推向风景呢?
更新:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
解决方法
在您的
viewWillAppear:
中,使用以下代码:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
, 在viewWillAppear中:在状态栏方向更改后,请执行以下操作:
//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];
希望它会有所帮助!
P.S.在sdk 3.2.5 ios 5.0.1上测试。