2012-10-16 46 views
1

我在我的应用程序中有两个视图。一个(默认)是风景。当用户点击某个菜单时,我需要出现一个纵向视图。从横向视图切换到iOS上的纵向视图

我已经具备了所有的代码,我尝试使用此:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 

     return (interfaceOrientation == UIInterfaceOrientationPortrait); 

} 

,但应用程序仍显示在园林中的下一个视图。我无法弄清楚这一点。任何帮助都会很棒。

回答

0

您可以使用下面的代码在你的viewWillAppear方法,使您的视图肖像。

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

它给我的错误: 'NSInteger的'(又名 'INT')以 'ID' 的演员是不允许使用ARC。 – nworksdev

+0

你必须禁用ARC才能使用此代码 –

+0

菜鸟错误。谢谢! – nworksdev

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); 
} 
相关问题