How to add a logout feature to an iPhone app?

谁都会走 提交于 2019-12-19 04:59:28

问题


I've an app with this layout:

When you open the app you see a login screen. You log in and you see a tabbar with 3 tabs. (The loginview is displayed with a presentModalView in the appdelegate of tabbar).

In the third tab there is a logout button. I want when logout button is pressed the app delete NSUserDefaults and shows the loginview again. And if you login again the login screen disappear and you see the first tab of the tabbar.

How can I do this?


回答1:


Do as follows,

  1. Place your login view in first view controller.

  2. Place your tabbar controller in second view controller.

  3. Store the second viewcontroller instance in appDelegate (this will be used for navigation).

  4. Now when the logout button is pressed,use the stored instance navigate your view.



来源:https://stackoverflow.com/questions/4320946/how-to-add-a-logout-feature-to-an-iphone-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!