控制 UIViewController 界面方向

发布于 2024-11-15 03:33:58 字数 320 浏览 4 评论 0原文

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

@implementation ParentViewController

- (id)init
{
   // some stuff
}

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

@end

现在我需要停止 childVC 的界面方向。

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

I have a UIViewController which contains a new UIViewController like below,

@implementation ParentViewController

- (id)init
{
   // some stuff
}

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

@end

Now i need to stop interfaceOrientation of childVC.

Is it possible, if so how??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初相遇 2024-11-22 03:33:58

尝试使用:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

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

来自文档

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

简而言之,如果您继承了 UIViewController 并且只想支持纵向,则无需执行任何操作。否则,您将需要添加此方法并决定是否允许旋转到另一个方向。

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

Try using:

 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

to any view controller to determine auto rotate behaviour.

From the documentation:

By default, this method returns YES for the UIInterfaceOrientationPortrait orientation only. If your view controller supports additional orientations, override this method and return YES for all orientations it supports.

In short, if you subclass UIViewController and only want to support portrait, you don't need to do anything. Otherwise you will need to add this method and decide whether to allow rotation to another orientation.

Read the section titled "Handling View Rotations".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文