【问题标题】:iOS 9 (on iPad only): UIWebView does not show select option elements anymoreiOS 9(仅限 iPad):UIWebView 不再显示选择选项元素
【发布时间】:2015-12-21 01:03:53
【问题描述】:

如果此下拉菜单加载到 WebView 中,它只会显示选择元素。通过单击框没有任何反应。如果此框有一个“单击”事件侦听器,调用警报,它会显示此警报,并在单击警报后显示列表。看起来列表被 WebView 隐藏了。请帮忙!

<select type="selector" class="selector" id="systemSelector" style="top: 30px;">
    <option value="0">Value</option>
    <option value="1">Value</option>
    <option value="2">Value</option>
    <option value="3">Value</option>
    <option value="4">Value</option>
    <option value="5">Value</option>
</select>

如果有输入字段,通过单击输入字段,它会显示键盘。在通过单击选择框显示键盘后,所有选项也会显示出来。

【问题讨论】:

  • 你找到解决办法了吗?
  • 是的,这个问题可以通过去掉 iOS8 的弹出窗口的解决方法代码来解决。显然在 iOS8 中弹出窗口存在问题,因此我们实现了一个委托方法来处理 iOS8 中的弹出窗口。此代码导致 iOS9 中的当前问题,不显示下拉菜单。

标签: select webview uiwebview ios9


【解决方案1】:

解决方案在我的代码中如下所示:

在您放置的 .m 文件的顶部:

#define IS_IOS8_3_AND_LOWER (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_8_3)

在@implementation 你放:

#if IF_IS_IOS8_3_AND_LOWER
/* Workaround for Apple bug (UIPopoverPresentationController ... should have a non-nil sourceView ...). */
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
        // Load resources for iOS 8.3 or earlier
        if ([viewControllerToPresent respondsToSelector:@selector(popoverPresentationController)]) {
            if (viewControllerToPresent.popoverPresentationController && !viewControllerToPresent.popoverPresentationController.sourceView) {
                return;
            }
        }
        [super presentViewController:viewControllerToPresent animated:flag completion:completion];
}
#endif

【讨论】:

  • presentViewController 方法何时被调用?我在警告框工作时面临完全相同的问题..
猜你喜欢
  • 2018-07-30
  • 2023-03-12
  • 1970-01-01
  • 2013-08-24
  • 2012-10-21
  • 2010-12-20
  • 1970-01-01
  • 1970-01-01
  • 2012-08-17
相关资源
最近更新 更多