gpt4 book ai didi

objective-c - iOS6自转混淆及对iOS5的支持

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:12:57 24 4
gpt4 key购买 nike

从 iOS6 开始,我意识到 shouldAutorotateToInterfaceOrientation: 方法已被弃用。我希望用户能够旋转我的大部分应用程序,这目前在 iOS6 和 5 中有效。但是,我有一个模态视图,我只想成为 portrait,所以我添加了以下内容,但它实际上没有工作(在模拟器和设备中测试):

// Tell the system what we support
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationPortrait;
}

// Tell the system It should autorotate
- (BOOL) shouldAutorotate {
return NO;
}

// Tell the system which initial orientation we want to have
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}

为什么这段代码没有阻止我的模态框旋转?如何在不让 iOS5 用户崩溃的情况下仍然支持 iOS5 方法和 iOS6 方法?

最佳答案

您必须将呈现的 vc 嵌入导航 Controller 中,您可以在其中设置首选方向。

https://stackoverflow.com/a/12522119

关于objective-c - iOS6自转混淆及对iOS5的支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13383848/

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