• <legend id='jSplG'><style id='jSplG'><dir id='jSplG'><q id='jSplG'></q></dir></style></legend>
  • <tfoot id='jSplG'></tfoot>
    1. <i id='jSplG'><tr id='jSplG'><dt id='jSplG'><q id='jSplG'><span id='jSplG'><b id='jSplG'><form id='jSplG'><ins id='jSplG'></ins><ul id='jSplG'></ul><sub id='jSplG'></sub></form><legend id='jSplG'></legend><bdo id='jSplG'><pre id='jSplG'><center id='jSplG'></center></pre></bdo></b><th id='jSplG'></th></span></q></dt></tr></i><div id='jSplG'><tfoot id='jSplG'></tfoot><dl id='jSplG'><fieldset id='jSplG'></fieldset></dl></div>
        <bdo id='jSplG'></bdo><ul id='jSplG'></ul>

        <small id='jSplG'></small><noframes id='jSplG'>

      1. iOS 8 SDK:模态 UIWebView 和相机/图像选择器

        时间:2023-10-23
        <legend id='mbnpM'><style id='mbnpM'><dir id='mbnpM'><q id='mbnpM'></q></dir></style></legend>
        • <i id='mbnpM'><tr id='mbnpM'><dt id='mbnpM'><q id='mbnpM'><span id='mbnpM'><b id='mbnpM'><form id='mbnpM'><ins id='mbnpM'></ins><ul id='mbnpM'></ul><sub id='mbnpM'></sub></form><legend id='mbnpM'></legend><bdo id='mbnpM'><pre id='mbnpM'><center id='mbnpM'></center></pre></bdo></b><th id='mbnpM'></th></span></q></dt></tr></i><div id='mbnpM'><tfoot id='mbnpM'></tfoot><dl id='mbnpM'><fieldset id='mbnpM'></fieldset></dl></div>
            • <bdo id='mbnpM'></bdo><ul id='mbnpM'></ul>

              <small id='mbnpM'></small><noframes id='mbnpM'>

                <tbody id='mbnpM'></tbody>
            • <tfoot id='mbnpM'></tfoot>

                  本文介绍了iOS 8 SDK:模态 UIWebView 和相机/图像选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我发现,在为 iOS 8 编译(并在 iOS 8 中运行)时,如果 UIWebView 位于视图控制器以模态方式呈现.它在直接挂"在窗口 rootViewController 上的视图控制器或从它推送的视图控制器中工作没有问题.

                  I have found that, when compiling for iOS 8 (and running in iOS 8), a UIWebView cannot show the camera/image picker if the UIWebView is in a view controller presented modally. It works without problem in view controllers directly "hanging" from the window rootViewController or view controllers pushed from it.

                  可以在 https://dl.dropboxusercontent.com/u/6214425/TestModalWebCamera 找到测试应用程序.zip 但我会在下面描述它.

                  The test application can be found at https://dl.dropboxusercontent.com/u/6214425/TestModalWebCamera.zip but I will describe it below.

                  我的测试应用程序(使用故事板构建,但真正的应用程序不使用它们)有两个视图控制器(原名为 ViewControllerViewController2).ViewController 包含在作为根视图控制器的 UINavigationController 中.ViewController 包含一个 UIWebView(工作正常)、一个显示"(推送")按钮 ViewController2 和一个 UIBarButtonItem 以模态方式呈现 ViewController2.ViewController2 有另一个 UIWebView,它在推送"时有效,但在呈现"时无效.

                  My test application (built with storyboards, but the real application doesn’t use them) has two view controllers (unoriginally named ViewController and ViewController2). ViewController is contained in a UINavigationController which is the root view controller. ViewController contains a UIWebView (works OK), a button that "shows" ("pushes") ViewController2, and a UIBarButtonItem which modally presents ViewController2. ViewController2 has another UIWebView which works when "pushed" but not when "presented".

                  ViewControllerViewController2 都加载了:

                  - (void)viewDidLoad {
                    [super viewDidLoad];
                  
                    [self.webView loadHTMLString:@"<input type="file" accept="image/*;capture=camera">" baseURL:nil];
                  }
                  

                  当尝试使用模态 UIWebView Xcode 在控制台中打印以下内容并关闭应用模态:

                  When trying to use the modal UIWebView Xcode prints the following in the console and dismisses the app modal:

                  Warning: Attempt to present <UIImagePickerController: 0x150ab800> on <ViewController2: 0x14623580> whose view is not in the window hierarchy!
                  

                  我目前的理论是 UIActionSheetUIAlertController 的变化可能会产生这种情况,但很难证明.以防万一,我会和 Apple 开一个 Radar.

                  My current theory is that the changes in UIActionSheet to UIAlertController might have produced this situation, but it’s quite hard to prove. I will open a Radar with Apple, just in case.

                  有没有人发现相同的情况和一些解决方法?

                  Has someone found the same situation and some workaround?

                  推荐答案

                  我发现在 iOS 8.0.2 iPad 似乎没有这个 bug 但 iPhone 仍然存在.

                  I found that in iOS 8.0.2 iPad does not seem to have that bug but iPhone still does.

                  但是,在包含 uiwebview 的视图控制器中覆盖以下内容

                  However, overriding following in the view controller containing the uiwebview

                  -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
                  

                  并且检查是否存在presentedViewController 似乎有效.

                  And checking that there is a presentedViewController seems to work.

                  但需要检查副作用

                  #import "UiWebViewVC.h"
                  
                  @interface UiWebViewVC ()
                  
                  @property (weak, nonatomic) IBOutlet UIWebView *uiwebview;
                  
                  @end
                  
                  @implementation UiWebViewVC
                  
                  - (void)viewDidLoad
                  {
                      [super viewDidLoad];
                  
                      NSURL *url = [NSURL URLWithString:@"http://html5demos.com/file-api-simple"];
                  
                      NSURLRequest *request = [NSURLRequest requestWithURL:url];
                  
                      self.uiwebview.scalesPageToFit = YES;
                  
                      [self.uiwebview loadRequest:request];
                  }
                  
                  
                  -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
                  {
                      if ( self.presentedViewController)
                      {
                          [super dismissViewControllerAnimated:flag completion:completion];
                      }
                  }
                  
                  
                  @end
                  

                  这篇关于iOS 8 SDK:模态 UIWebView 和相机/图像选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:UIWebView - 如何识别“最后一个"webViewDidFinishLoad 消息? 下一篇:将 CSS 插入 UIWebView/WKWebView 中加载的 HTML

                  相关文章

                  <legend id='Qjlvz'><style id='Qjlvz'><dir id='Qjlvz'><q id='Qjlvz'></q></dir></style></legend>

                  <small id='Qjlvz'></small><noframes id='Qjlvz'>

                  <i id='Qjlvz'><tr id='Qjlvz'><dt id='Qjlvz'><q id='Qjlvz'><span id='Qjlvz'><b id='Qjlvz'><form id='Qjlvz'><ins id='Qjlvz'></ins><ul id='Qjlvz'></ul><sub id='Qjlvz'></sub></form><legend id='Qjlvz'></legend><bdo id='Qjlvz'><pre id='Qjlvz'><center id='Qjlvz'></center></pre></bdo></b><th id='Qjlvz'></th></span></q></dt></tr></i><div id='Qjlvz'><tfoot id='Qjlvz'></tfoot><dl id='Qjlvz'><fieldset id='Qjlvz'></fieldset></dl></div>
                • <tfoot id='Qjlvz'></tfoot>

                      <bdo id='Qjlvz'></bdo><ul id='Qjlvz'></ul>