Iphone 在iOS上从横向视图切换到纵向视图

Iphone 在iOS上从横向视图切换到纵向视图,iphone,ios,uiview,orientation,Iphone,Ios,Uiview,Orientation,我的应用程序中有两个视图。一个(默认情况下)是横向。当用户单击某个菜单时,我需要显示一个纵向视图 我已经准备好了所有的代码,我正在尝试使用: - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } 但该应用程序仍会在

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

我已经准备好了所有的代码,我正在尝试使用:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

      return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

但该应用程序仍会在横向视图中显示下一个视图。我想不出来。任何帮助都会很好。

您可以在
视图中使用以下代码将出现
方法使视图具有纵向效果

 [[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(id)UIInterfaceOrientationPortrait];

您可以在
视图中使用以下代码来显示视图

 [[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:") withObject:(id)UIInterfaceOrientationPortrait];

这给了我一个错误:ARC不允许将'NSInteger'(也称为'int')施法到'id'。能够构建,但不幸的是仍然没有骰子。我需要一个特定的shouldAutorotateToInterfaceOrientation方法吗?不需要,请您对整个
shouldAutorotateToInterfaceOrientation
method进行注释。如果您使用的是ARC,那么您可以仅对单个文件禁用它并成功运行项目。下面是禁用ARC的链接,它给了我一个错误:ARC不允许将'NSInteger'(也称为'int')转换为'id'。能够构建,但不幸的是仍然没有骰子。我需要一个特定的shouldAutorotateToInterfaceOrientation方法吗?不需要,请您对整个
shouldAutorotateToInterfaceOrientation
method进行注释。如果您使用的是ARC,那么您可以仅对单个文件禁用它并成功运行项目。下面是禁用ARC的链接