2017-02-17 4 views
0

私は自分のウェブアプリケーションを1つのウェブビューに残し、サファリのドメイン外にリンクを開くようにしました。私がする必要があるのは、サファリで開くドメインにある.pdfファイルを追加することです。今のところ、彼らはWebビューで開き、そこから抜け出すためのナビゲーションがないので、アプリケーションを強制的に強制して再起動する必要があります。あなたは、ナビゲーションを追加したい場合は私のウェブビューアプリからサファリの.pdfファイルを開く方法

- (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; 
} 

答えて

0

あなたはSFSafariViewController

を使用する必要があり、その迅速なコードの例

let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!, entersReaderIfAvailable: true) 
self.presentViewController(svc, animated: true, completion: nil) 
あなたは thisチュートリアルでより多くの情報を見つけることができます

関連する問題