gpt4 book ai didi

iphone - 为什么这个方向代码不起作用?

转载 作者:行者123 更新时间:2023-12-01 19:22:36 25 4
gpt4 key购买 nike

我有一个简单的 UIWebView 嵌套在 ViewController 中,它以模态方式呈现在导航 Controller 之外。

结构如下:TableViewController -> TableViewController -> Modal(WebView呈现)-> Modal(选项,通过手势呈现,页面 curl )

所有 View 都处理所有方向,除了上面有 WebView 的那个,它是通过配置来处理它的方向。

带有 Web View 的 Controller 具有以下方向代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
BOOL orientationSwitch = NO;

if([self.webApp.orientationLandscape boolValue] &&
UIInterfaceOrientationIsLandscape(interfaceOrientation))
orientationSwitch = YES;

if([self.webApp.orientationPortrait boolValue] &&
UIInterfaceOrientationIsPortrait(interfaceOrientation))
orientationSwitch = YES;

return orientationSwitch;
}

现在的目的是您可以设置一些选项来决定 View 是否应该对方向变化使用react。在大多数情况下它可以工作,但是我有一个模态弹出窗口,您可以在其中选择关闭包含 Web View 的模态。一旦发生这种情况,似乎整个应用程序的方向都被锁定了。所有其他 View 随后不响应任何形式的旋转。

有任何想法吗?

谢谢

最佳答案

这里有一些东西可以尝试。向 UIDevice 注册 UIDeviceOrientationDidChangeNotification 并告诉它开始生成通知。当有通知进来时,调用 UIViewController 类方法attemptRotationToDeviceOrientation (仅限 iOS 5)。

此外,阅读此技术说明可能会有所帮助,因为您可能在这里做错了:https://developer.apple.com/library/ios/#qa/qa1688/_index.html

关于iphone - 为什么这个方向代码不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9450687/

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