gpt4 book ai didi

ios - 当 View 从纵向更改为横向时,方向不会改变

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

我有只有纵向的菜单和可以纵向或横向的详细 View (使用 UIWebView)。

当我进入详细 View 并旋转设备横向并以这种方式从该屏幕返回到应该仅为纵向的菜单时,菜单处于横向(以及状态栏和导航栏)。

有没有办法避免这种情况并强制将屏幕旋转到所需(支持的)方向?

最佳答案

@kkumpavat 提出的解决方案对我没有用,或者它不够清晰,我无法理解。我做了更多搜索并找到了使用以下方法的解决方案:

    // http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation
// http://openradar.appspot.com/radar?id=697
[[UIDevice currentDevice] performSelector:NSSelectorFromString(@"setOrientation:")
withObject:UIInterfaceOrientationPortrait];

但这会产生恼人的警告,我将其替换为:

//force update of screen orientation
if (self.interfaceOrientation != [self preferredInterfaceOrientationForPresentation]) {
[[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: [self preferredInterfaceOrientationForPresentation]]
forKey:@"orientation"];
}

从 NavigationController 的 viewDidAppear 调用。

关于ios - 当 View 从纵向更改为横向时,方向不会改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24141449/

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