从处于风景中的视图控制器将肖像中的视图控制器推入

问题描述

|| 我有一个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上测试。     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...