1

我的应用程序中有两个视图。一个(默认情况下)是横向。当用户单击某个菜单时,我需要出现纵向视图。

我有所有的代码,我正在尝试使用它:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

      return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

但该应用程序仍以横向显示下一个视图。我想不通。任何帮助都会很棒。

4

2 回答 2

1
You can not do it using navigation controller but if you are presenting your view then it  is possible to do that and make sure when you are presenting your view animation should be NO.
It works for me very well.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
于 2012-10-16T05:33:40.597 回答
0

您可以在您的viewWillAppear方法中使用以下代码来制作您的视图肖像。

 [[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(id)UIInterfaceOrientationPortrait];
于 2012-10-16T04:45:42.003 回答