简体   繁体   中英

Load view controller without displaying nib

I have a button that presents a view controller containing login elements including a Facebook login button. Once the user logs in successfully the view controller is automatically dismissed and user returns to the previous screen.

I am trying to implement an auto login feature whereby cached tokens can auto login ie the user does not have to tap the button which presents the secondary view. Currently the logic around checking for cached tokens works fine, and once I load the view it instantly logs in and removes the view without me having to do anything. However I want to be able to trigger this without actually showing the view itself. Is there a way to show the view but make non visible? Or how are such scenarios meant to be implemented?

Currently I have

self.loginVC = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
self.loginVC.delegate = self;
self.loginVC.modalTransitionStyle = UIModalPresentationFormSheet;
[self presentViewController:self.loginVC animated:YES completion:^(void){}];
  1. Create a class LoginAuth that performs only the network calls for login authentication.
  2. whenever you want loginVC to show up, awake the nib , call the LoginAuth and perform dismiss on successful authentication.
  3. For auto login, directly call the LoginAuth for authentication via cached tokens in background; if that is successful go ahead, else show the LoginVC for logging in again

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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