在Safari View Controller中打开WebView链接。 (Xcode,Swift)

时间:2015-09-15 10:36:20

标签: view webview safari controller ios9

我正在尝试在Safari View Controller中打开各种WebView链接。

因此,在WebView(Swift)中,我需要能够在Safari View Controller中打开所有外部链接,但在WebView(自己)中打开的内部链接除外。

1 个答案:

答案 0 :(得分:1)

//MARK: Button Click on open with SafariViewController

private var urlString:String = "https://google.com"

@IBAction func openWithSafariVC(sender: AnyObject)
{
    let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)
    svc.delegate = self
    self.presentViewController(svc, animated: true, completion: nil)
}
//MARK: SafatriViewConroller Dismiss 

func safariViewControllerDidFinish(controller: SFSafariViewController)
{
    controller.dismissViewControllerAnimated(true, completion: nil)
}