swift2 - mac osx app - swift window & viewcontroller fullscreen/resize -
i trying work out how windowcontroller , viewcontroller can talk each other when user clicks on windowcontroller fullscreen or manually resizes screen.
i have uploaded full code github, noob @ swift , not sure parts of script need.
but here part of code
// // viewcontroller.swift // slither.io // // created russell harrower on 1/06/2016. // copyright © 2016 russell harrower. rights reserved. // import cocoa import webkit class viewcontroller: nsviewcontroller { @iboutlet weak var webview:wkwebview! override func viewwillappear() { super.viewwillappear() preferredcontentsize = view.fittingsize } override func viewdidload() { super.viewdidload() //let webviewconfiguration: wkwebviewconfiguration = wkwebviewconfiguration() let webview: wkwebview = wkwebview(frame:self.view.frame) let urlstring = nsurl(string:"http://slither.io") let requestobj = nsurlrequest(url: urlstring!) webview.loadrequest(requestobj) self.view.addsubview(webview) //self.webview.mainframe.loadrequest(nsurlrequest(url: nsurl(string: urlstring)!)) } override var representedobject: anyobject? { didset { // update view, if loaded. } } }
you can see full xcodeproject @ https://github.com/russellharrower/slither.io-mac-app
set constrains of webview super view. (i have set web view constrains in storyboard sure can in run time too)