0

我有一个UIViewController包含一个新的UIViewController,如下所示,

@implementation ParentViewController

- (id)init
{
   // some stuff
}

- (BOOL)CreateChildViewController
{
   UIViewController *childVC = [[UIViewController alloc] init];
}

@end

现在我需要停止 childVC 的 interfaceOrientation。

有可能吗,如果可以怎么办??

4

1 回答 1

0

尝试使用:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

到任何视图控制器以确定自动旋转行为。

文档中:

默认情况下,此方法仅对 UIInterfaceOrientationPortrait 方向返回 YES。如果您的视图控制器支持其他方向,请覆盖此方法并为其支持的所有方向返回 YES。

简而言之,如果你子类化UIViewController并且只想支持肖像,你不需要做任何事情。否则,您将需要添加此方法并决定是否允许旋转到另一个方向。

阅读标题为“处理视图旋转”的部分。

于 2011-06-10T14:59:43.973 回答