How can I manually switch between UIViewControllers in storyboard?

后端 未结 4 2353
你的背包
你的背包 2020-12-01 03:00

All I need is to view a UIView controller in same storyboard file manually with code. I use storyboard to make all forms and connections. My application starts

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 03:45

    In this statement:

    [self.view pushViewController:LoginViewController animated:YES];
    

    it seems you are trying to push a class. You should push an object, your actual controller:

    LoginViewController* controller = [[LoginViewController alloc] init...];
    [self.view pushViewController:controller animated:YES];
    

    this will at least compile, and if all the rest is fine, also give you the second controller.

    EDIT:

    I missed one point. You are pushing the view controller on to a view. That makes no sense, you should push the controller on to the navigation controller:

     *del = (AppDelegate*)[UIApplication sharedApplication].delegate;
    [del.navigationController pushViewController:controller animated:YES];
    

    This is true, at least, if you created your project from the Navigation-based template (which creates an application delegate with a reference to the navigation controller). Otherwise, please provide details about how you create the navigation controller.

提交回复
热议问题