SKSafariViewController未在iOS

时间:2017-06-02 06:16:39

标签: ios objective-c iphone

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

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

iPhone Safari应用程序打开并要求我选择使用特定的App' AIP Viewer'

打开

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

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

SKSafariViewController打开但是空白。

2 个答案:

答案 0 :(得分:0)

/*! @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:// *

答案 1 :(得分:0)

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];

}
相关问题