这里是开发和网站方面的新手。
基本上我想设计一个应用程序,显示启动屏幕(我已经成功做到了),然后显示一个信息屏幕,告诉用户设置密码以访问应用程序,最后要求用户设置 4 位密码然后每次打开该应用程序时,它都会要求用户输入密码。
所以问题是如何做到这一点?
我可能要求很多,但如果你们能指导我,那就太好了:)
最佳答案
要制作此应用,您需要使用 NSUserDefaults
。最简单的方法是创建一个 bool 变量,告诉应用程序密码已经设置,或者如果没有将它发送到另一个 viewController 来设置它。
在 NSUserDefaults 上存储值
当用户完成设置他的第一个密码并确认后,将值保存在 NSUserDefaults
上, key 为 AppUsageCheck
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"AppUsageCheck"];
读值返回
//On application didFinishLaunchingWithOptions
//If this value exists, check it if the user has set his password
if ([[NSUserDefaults standardUserDefaults] objectForKey:@"AppUsageCheck"])
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AppUsageCheck"]==YES) {
//User has set it already, so go and show the user to enter his password
}
else
{
//User has to set the password, because he doesn't have one
}
}
else
{
//User has to set the password, because he doesn't have one
}
关于ios - iOS 7 一次显示信息屏幕和设置密码屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23269277/