2015-10-01 5 views
0

Я пытаюсь реализовать пользовательское поведение peek/pop в WkWebView. Я вижу, как делегат вызывается, и контроллер возвращается, но контроллер peek не отображается.Custom 3D touch и проблема WkWebView

я могу получить только контроллер заглядывать к showup, установив self.webView? .userInteractionEnabled = ложь

Что может быть здесь происходит?

Код:

class ViewController: UIViewController, WKNavigationDelegate, UIViewControllerPreviewingDelegate { 

var webView: WKWebView? 

func webView(webView: WKWebView, 
    decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, 
    decisionHandler: ((WKNavigationResponsePolicy) -> Void)){ 

     decisionHandler(.Allow) 
} 

override func viewDidLoad() { 
    super.viewDidLoad() 

    /* Create our preferences on how the web page should be loaded */ 
    let preferences = WKPreferences() 
    preferences.javaScriptEnabled = true 

    /* Create a configuration for our preferences */ 
    let configuration = WKWebViewConfiguration() 
    configuration.preferences = preferences 

    /* Now instantiate the web view */ 
    webView = WKWebView(frame: view.bounds, configuration: configuration) 

    if let theWebView = webView{ 
     /* Load a web page into our web view */ 
     let url = NSURL(string: "http://www.apple.com") 
     let urlRequest = NSURLRequest(URL: url!) 
     theWebView.loadRequest(urlRequest) 
     theWebView.navigationDelegate = self 
     view.addSubview(theWebView) 

    } 

    self.registerForPreviewingWithDelegate(self, sourceView: self.view) 
} 

func previewingContext(previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { 

    self.webView?.userInteractionEnabled = false 
    let peekViewController = storyboard!.instantiateViewControllerWithIdentifier("peekaboo") as UIViewController 
    /* 
    Set the height of the preview by setting the preferred content size of the detail view controller. 
    Width should be zero, because it's not used in portrait. 
    */ 
    peekViewController.preferredContentSize = CGSize(width: 0.0, height: 0.0) 

    // Set the source rect to the cell frame, so surrounding elements are blurred. 
    //previewingContext.sourceRect = (self.webkitWebView?.frame)! 

    return peekViewController 
} 

/// Present the view controller for the "Pop" action. 
func previewingContext(previewingContext: UIViewControllerPreviewing, commitViewController viewControllerToCommit: UIViewController) { 
    // Reuse the "Peek" view controller for presentation. 

} 
} 
+0

Я вижу, что он пытается загрузить контроллер, но он никогда не показывает вверх .... –

ответ

0

Установить высоту prefferedContentSize

peekViewController.preferredContentSize = CGSize(width: 0.0, height: 150) 
Смежные вопросы