【问题标题】:SKSafariViewController Not opening Protected pdf in iOSSKSafariViewController 未在 iOS 中打开受保护的 pdf
【发布时间】:2017-06-02 06:16:38
【问题描述】:

我有一个受 RMS 保护的 pdf 文件,例如“sample.ppdf”。 它是从 URL 加载的。

现在当我实现以下内容时: UIApplication.SharedApplication.OpenUrl(new NSUrl(_documentUrl));

iPhone Safari 应用程序打开并要求我选择使用特定应用程序“AIP 查看器”打开

现在,当我尝试使用以下代码实现相同的功能时:

    SFSafariViewController *svc = [[SFSafariViewController alloc] initWithURL:url];
svc.delegate = self;
[self presentViewController:svc animated:YES completion:nil];

SKSafariViewController 打开但为空白。

【问题讨论】:

    标签: ios objective-c iphone


    【解决方案1】:
    /*! @abstract Returns a view controller that loads a URL.
        @param URL the initial URL to navigate to. Only supports initial URLs with http:// or https:// schemes.
     */
    - (instancetype)initWithURL:(NSURL *)URL;
    

    确保您的网址是 http://* 或 https://*

    【讨论】:

      【解决方案2】:

      SFSafariViewController 与版本iOS 9.0+ 兼容。放版本检查iOS version是否小于iOS 9.0直接在safari浏览器打开。

      试试这个,

      NSURL *urlAsString = [NSURL URLWithString:[NSString stringWithFormat:@"Your_URL"]];
      
       if ([SFSafariViewController class] != nil)  {
      
         SFSafariViewController *sfvc = [[SFSafariViewController alloc] initWithURL:urlAsString];
      
         [self presentViewController:sfvc animated:YES completion:nil];
      
      } 
      else {
          [[UIApplication sharedApplication] openURL:urlAsString];
      
      }
      

      【讨论】:

        猜你喜欢
        • 2020-12-17
        • 1970-01-01
        • 2014-11-25
        • 2021-03-28
        • 1970-01-01
        • 1970-01-01
        • 2015-07-20
        • 2013-07-14
        相关资源
        最近更新 更多