ios - WKWebView add as a subview -


from ios 8.0+, supposed use wkwebview, in official apple documentation, add setting view wkwebview. need add subview, numerous reasons.

  1. i have add buttons/labels above wkwebview.
  2. i can add adding uiview storyboard , setting code wkwebview, looks neater adding code.

my code:

@iboutlet weak var container: uiview!  private var wkwebview: wkwebview!  override func loadview() {     let webconfig = wkwebviewconfiguration()     wkwebview = wkwebview(frame: .zero, configuration: webconfig)     wkwebview.uidelegate = self }  override func viewdidload() {     super.viewdidload()      container = wkwebview      let url = url(string: "https://google.com")     let request = urlrequest(url: url!)     wkwebview.load(request) } 

i have tried this: wkwebview add subview

i have tried container.addsubview method, crashed nil pointer.

every time load app, there's black screen.

any ideas?

you should add instance of wkwebview subview given view:

view.addsubview(wkwebview) 

you can set frame, add constraints etc., uiview.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -