如何从我的网络视图应用程序打开safari中的.pdf文件

时间:2017-02-17 20:33:27

标签: ios

我的网络应用程序停留在一个Web视图中,并在Safari中打开域外链接。我需要做的是添加域中的.pdf文件以在safari中打开。截至目前,他们在网络视图中打开,没有导航退出它,所以你必须强制相当的应用程序并重新启动。

    - (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://rbc.samkingmedia.com"]]];
    _webView.delegate = self;
    [_webView addSubview:activityind];
    timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(loading) userInfo:nil repeats:YES];

}

-(void)loading {
    if (!_webView.loading)
        [activityind stopAnimating];
    else
        [activityind startAnimating];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {


    //  open External Links (not beginning with www.playbuzz.org/ in Safari.app
    if (
        (navigationType == UIWebViewNavigationTypeLinkClicked) &&
        ( ![[[request URL] absoluteString] hasPrefix:@"http://rbc.samkingmedia.com/"])
        ) {

        [[UIApplication sharedApplication] openURL:request.URL];
        return NO;
    }

    //open Internal links in uiwebview
    return YES;
}

1 个答案:

答案 0 :(得分:0)

如果要添加导航,则应使用SFSafariViewController

它是swift代码中的一个例子

C = [A(:);B(:)];

您可以在中找到更多信息 this教程