5 Replies
      Latest reply: Feb 10, 2017 6:34 AM by Pendragon RSS
      Pendragon Level 1 Level 1 (0 points)

        I started a cocoa swift storyboard app for osx. After looking at some videos n such nearly every time I see override or just func webView(...), but as I type this in it doesn't show anything. Has this been removed ?

         

        I started out trying to make a progress indicator but as mentioned following a tutorial doesn't help. In help documentation I always get lost because there are no examples, it referes to WebViewProgressStarted but I have no idea about notifications, I'm a newbie to programming.

         

        In a ViewController I have a text field and webview (app trans set to arbitrary), using webview load works fine to load an url but is there a way to get the full url of the page being loaded to replace the text field ? To acompany this when I click a link within a page to get the url into the text field.

        • Re: xcode 8.2.1 func webview ?
          KMT Level 8 Level 8 (9,960 points)

               >xcode 8.2.1 func webview

           

          WKWebView may be your friend now. WebView (legacy) is also still allowed w/macOS, but it depends on your usage, I think.

            • Re: xcode 8.2.1 func webview ?
              Pendragon Level 1 Level 1 (0 points)

              I'm not understanding what's wrong here. If I insert a web view object "WebKit View" and link outlet to ViewController, it wants to be WebView not WKWebView. This is all I can find.

                • Re: xcode 8.2.1 func webview ?
                  KMT Level 8 Level 8 (9,960 points)

                  WebKitView (view object) = Webview

                  WKWebView (view object) = WKWebView

                   

                  Which of the below examples would you say applies to your use case:

                   

                  WebView

                  WebView is the core view class in the WebKit framework that manages interactions between the WebFrame and WebFrameView classes. To embed web content in your application, you just create a WebView object, attach it to a window, and send a load(_:) message to its main frame.

                  -=-

                  WKWebView

                  A WKWebView object displays interactive web content, such as for an in-app browser. You can use the WKWebView class to embed web content in your app. To do so, create a WKWebView object, set it as the view, and send it a request to load web content.

                  • Re: xcode 8.2.1 func webview ?
                    eskimo Apple Staff Apple Staff (7,960 points)

                    If I insert a web view object "WebKit View" and link outlet to ViewController, it wants to be WebView not WKWebView.

                    You cannot add a WKWebView via Interface Builder.  You have to construct it in code.  This is a long-standing bug that we’re tracking as (r. 16729039).  So, the WebKit View shown by IB yields the not-deprecated-but-not-preferred WebView.  You can continue using WebView if you like, but I generally recommend WKWebView instead.

                    Adopting WKWebView means constructing the view in code.  In my experience that’s not too tricky.  Here’s the code I use to do it in iOS:

                    override func loadView() {
                        let config = WKWebViewConfiguration()
                        let webView = WKWebView(frame: CGRect.zero, configuration: config)
                        webView.navigationDelegate = self
                        self.view = webView
                    }
                    

                    I expect that the macOS version will be very similar (assuming you’re using a view controller).

                    Once you decide on a web view, post back with a status update on your original problem and we can try to help out from there.

                    Share and Enjoy

                    Quinn “The Eskimo!”
                    Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                    let myEmail = "eskimo" + "1" + "@apple.com"