简体   繁体   中英

iOS Storyboard change initial view

I've been trying to change the initial view in app delegate by putting this code

if(![[NSUserDefaults standardUserDefaults] valueForKey:@"userId"]) {
    LogInViewController* lvc = [[LogInViewController alloc]init];
    [self.navigationController pushViewController: lvc animated:YES];
}else {
    PerfilViewController *pvc = [[PerfilViewController alloc]init];
    [self.navigationController pushViewController: pvc animated:YES];
}

i have swrevealviewcontroller in my storyboard as its shown beneath, the red one is the one when its not logged in and the blue one is when its logged in

在此处输入图片说明

Try this. Instead of having multiple arrows, have only one that points to the very first view (LogInViewController). Then, in the viewDidLoad function of LogInViewController, place your checker code. You could then have a segue from LogInViewController over to PerfilViewController that is performed if the user is logged in; otherwise, stay on LogInViewController.

viewDidLoad{
  [super viewDidLoad];
  if([[NSUserDefaults standardUserDefaults] valueForKey:@"userId"]){
      [self performSegueWithIdentifier:@"toProfile" sender: self];
}

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