简体   繁体   English

ios上的一次登录屏幕

[英]One time login screen on ios

I'm creating an application and on the user first time use I will need them to give me their API Token to access the application, but I just need this login to show up one time, and after I will store the token on a NSUserDefaults. 我正在创建一个应用程序,并且在用户第一次使用时,我需要他们给我他们的API令牌来访问该应用程序,但是我只需要显示此登录一次,然后将令牌存储在NSUserDefaults上即可。 。

My question is, I'm using storyboards and theoretically the login screen would be my root view... but after I have the token I want to skip this part, so how would I do it? 我的问题是,我正在使用情节提要,并且从理论上讲,登录屏幕将是我的根视图...但是获得令牌后,我想跳过此部分,那么我将如何做呢? should I create a separated xib file just for the login screen? 我应该只为登录屏幕创建单独的xib文件吗?

Then on the app delegate I would check if the Token is present and either call the xib or the storyboard file. 然后在应用程序代表处,我将检查令牌是否存在,并调用xib或情节提要文件。 Not sure if this is the best approach, does anyone would recommend something more efficient? 不知道这是否是最好的方法,有人会推荐更有效的方法吗?

Thanks 谢谢

在此处输入图片说明

Add stoyboardId for login and home view controller in storyboard 在故事板中为登录和主视图控制器添加stoyboardId

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
 NSString *identifier;
 BOOL isSaved = [[NSUserDefaults standardUserDefaults] boolForKey:@"loginSaved"];
 if (isSaved)
  {
   identifier=@"home";
  }
 else
  {
   identifier=@"login";
  }
UIStoryboard *    storyboardobj=[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *screen = [storyboardobj instantiateViewControllerWithIdentifier:identifier];
[self.window setRootViewController:screen];
return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM