ios - Show login Screen when hitting Homebutton -
i have swift project wich needs switch login viewcontroller when user hits homebutton or appswitcher (like bankingapps or 1password does). login viewcontroller initial vc. searched since few days, couldn't find information that. how implement in project?
thank you
dirk
simplifying little on @holex , comments (and working without notifications) solution require navigation based on uinavigationcontroller
login viewcontroller set rootviewcontroller
.
edit: ensure app using uinavigationcontroller
described above:
open
main.storyboard
otherwise select current root view controller
- from menu choose editor > embed in > navigation controller
- if don't want navigation bar visible, disable "shows navigation bar" option
end of edit
in constellation in application delegate:
// called before uiapplicationwillresignactivenotification posted func applicationwillresignactive(application: uiapplication) { if let keywindow = application.keywindow, navvc = keywindow.rootviewcontroller as? uinavigationcontroller { navvc.poptorootviewcontrolleranimated(true) } }
this forces pop-to-root whenever app looses focus. cite apple docs:
[the app] loses focus when overlay window pops or when device locked,
using application switcher or pressing home button both should count in category.
i placed sample project on github
Comments
Post a Comment