【问题标题】:iOS5: UIWebView doesn’t display Gmail after some attachment files were openediOS5:打开某些附件文件后,UIWebView 不显示 Gmail
【发布时间】:2011-11-07 08:56:17
【问题描述】:

是否有任何解决方案/解决方法?

总结:

在 iOS5 设备/模拟器上,带有 UIWebView 的应用程序在打开某些类型的附件文件(例如 .pdf、.txt 或 .xml)后不会显示 Gmail。我用 UIWebView 构建了一些简单的应用程序,其中有 searchBar、goBack 按钮等。当它们为 iOS 4.3 构建时,它们可以在 iPhone 4.3 设备/模拟器上完美运行,但在 5.0 上则不能。为 iOS5 构建的项目也存在同样的问题。

复制步骤:

  1. 使用 UIWebView 构建面向 iOS 4.3 或 5.0 的应用,其中至少有一个返回按钮和一个用于 URL 的搜索栏。
  2. 在 iOS5 设备/模拟器上运行应用程序。
  3. 在应用中登录 Gmail。
  4. 打开一封电子邮件的 pdf (txt / xml) 附件。 (打开 UIWebView 支持的 Microsoft Office 文件时不会出现此问题,例如 word、excel 和 powerpoint。)
  5. 按“返回”按钮返回上一页,或在搜索栏中输入网址“http://mail.google.com”。
  6. UIWebView 显示白色空白。
  7. 之后,您将再也看不到自己的 Gmail 页面了。

预期结果:

您可以返回上一封电子邮件(当您按下返回按钮时),或转到 Gmail 页面的顶部(当您输入 Gmail URL 时)。

实际结果:

UIWebView 只是显示一个白色空白,永远不会让您看到任何 Gmail 页面。

回归:

发生: - iOS 部署目标 4.3,在 iOS 5.0 设备/模拟器上运行 - iOS 部署目标 5.0,在 iOS 5.0 设备/模拟器上运行

不发生: - iOS 部署目标 4.3,在 iOS 4.3 设备/模拟器上运行

谢谢

【问题讨论】:

    标签: uiwebview webkit gmail ios5 attachment


    【解决方案1】:

    我遇到了同样的问题,但无法解决。我建议您使用一种解决方法。 如果您的 UIWebView 转到 "mail-attachment.googleusercontent.com" ,则返回 动作是错误的。因此,当检测到 URL 时,您最好创建另一个视图并在其上加载附件。第二个有返回按钮,但是当它被按下时,你会丢弃第二个视图,然后通过 IBAction 方法返回到第一个视图。它适用于 iOS4 和 iOS5。

    我的示例代码如下。

    -(BOOL) firstView:(UIWebView *)view
    shouldStartLoadWithRequest:(NSURLRequest *)req
     navigationType:(UIWebViewNavigationType)nType{
        NSString *strurl=[[[req URL] standardizedURL] absoluteString];
        NSRange range=[strurl rangeOfString: @"mail-attachment" options:NSCaseInsensitiveSearch];
        if (range.location!=NSNotFound){
            Your2ndViewController *attView = [[Your2ndViewController alloc] initWithNibName:@"YourNibNameofAnothor" bundle:nil];
            if(attView==nil){
                return NO;
            }
            attView.wvc=self;//mark the first on the second to return the first one
                [attView loadURLWithString:strurl];
            [self.view addSubview:attView.view ];
            [UIView commitAnimations];
            [attView loadURLWithString:strurl];
            return NO;//Not Load on the first view
        }
        return YES;//Load on the first view
    }
    

    你的第二个视图也是 UIWebView 有一个返回按钮,它的处理程序正在跟随

    - (IBAction) returnParent:(id)sender
    {
        [self.view removeFromSuperview];//return to the first view
        [UIView commitAnimations];
    }
    

    【讨论】:

    • 感谢您的回复。我确认了您建议的方式确实有效。我向苹果和谷歌报告了这个问题。希望尽快修复!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-13
    • 2011-10-15
    • 1970-01-01
    • 1970-01-01
    • 2014-07-21
    相关资源
    最近更新 更多