Detecting screen transition (switching) globally in iOS with Swift -
i wondering if there way detect screen switching globally in app, e.g. application delegate? know there methods ismovingfromparentviewcontroller() , ismovingtoparentviewcontroller(), can used locally. info helpful, thanks!
kristian
if going use global uinavigationcontroller
rootviewcontroller
uiwindow
in appdelegate
in following way.
let navigationcontroller:uinavigationcontroller = uinavigationcontroller(rootviewcontroller: viewcontroller()) navigationcontroller.delegate = self window = uiwindow(frame: uiscreen.main.bounds) window?.rootviewcontroller = navigationcontroller window?.makekeyandvisible()
then following delegate methods in uinavigationcontrollerdelegate
work in appdelegate
func navigationcontroller(_ navigationcontroller: uinavigationcontroller, didshow viewcontroller: uiviewcontroller, animated: bool) { } func navigationcontroller(_ navigationcontroller: uinavigationcontroller, willshow viewcontroller: uiviewcontroller, animated: bool) { }
the above functions when new uiviewcontroller
shows in uinavigationcontroller
. unfortunately, there no such methods related uiwindow
observe changes. please let me know if helps.
Comments
Post a Comment