目标C - 显示信息屏幕并设置密码屏幕一次iOS 7



这里是开发和网站方面的新手。

基本上,我想设计一个应用程序,它显示启动屏幕(我已经做到了),然后显示一个信息屏幕,告诉用户设置访问应用程序的密码,然后最后要求用户设置4位密码,然后每次打开应用程序时,它都会要求用户提供密码。

所以问题是如何做到这一点?

我可能要求很多,但如果你们能指导我,那就太好了:)

要制作此应用程序,您需要使用NSUserDefaults。最简单的方法是创建一个bool变量,告诉应用程序密码已经设置,或者如果没有,将其发送到另一个viewController进行设置。

在NSUserDefaults上存储值

当用户完成设置第一个密码并确认后,使用AppUsageCheck键将值保存在NSUserDefaults

[[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
}

最新更新