如何向 iPhone 应用程序添加注销功能?
我有一个具有以下布局的应用程序:
当您打开该应用程序时,您会看到一个登录屏幕。您登录后会看到一个包含 3 个选项卡的选项卡栏。 (登录视图在选项卡栏的appdelegate中显示为presentModalView)。
在第三个选项卡中有一个注销按钮。我希望当按下注销按钮时应用程序删除 NSUserDefaults 并再次显示登录视图。如果您再次登录,登录屏幕就会消失,您会看到选项卡栏的第一个选项卡。
我该怎么做?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行以下操作,
将您的登录视图放置在第一个视图控制器中。
将标签栏控制器放置在第二个视图控制器中。
将第二个 viewcontroller 实例存储在 appDelegate 中(这将用于导航)。
现在,当按下注销按钮时,使用存储的实例导航您的视图。
Do as follows,
Place your login view in first view controller.
Place your tabbar controller in second view controller.
Store the second viewcontroller instance in appDelegate (this will be used for navigation).
Now when the logout button is pressed,use the stored instance navigate your view.