gpt4 book ai didi

iphone - 在用户操作时旋转 UIViewController

转载 作者:行者123 更新时间:2023-11-29 04:29:48 25 4
gpt4 key购买 nike

我拥有的:

我有一个支持纵向和横向的 View Controller 。当处于横向时,我会显示纵向内容的过滤器 View 。

我需要做什么:

当用户在横向 View 中选择过滤器时,我想强制将设备旋转回纵向。

我做了一些谷歌搜索并发现

[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];

这是一个私有(private) API,我不想这样做。 (但这正是我所追求的)

简而言之 - 在用户操作时我想强制旋转设备。我在文档中遗漏了什么吗?

任何想法都会很棒。丹

最佳答案

这是从经验中学到的!在您的 viewDidLoad::

中执行此操作
UIViewController *vc = [[UIViewController alloc] init];
[self presentModalViewControllerAnimated:NO];
[self dismissModalViewControllerAnimated:NO];

如果您仅对横向的 shouldAutorotateToInterfaceOrientation 返回 YES,它将强制横向。没有私有(private) API!

关于iphone - 在用户操作时旋转 UIViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11884695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com