search

Home  >  Q&A  >  body text

Problems with storyboard in iOS

Two interfaces are set up in the storyboard.

Use

in your code
[self.navigationController pushViewController:[[SCMainViewController alloc]init] animated:YES];

How to jump to the past without loading

Can't we use pure code to jump anymore? . Can I only use segue?

伊谢尔伦伊谢尔伦2775 days ago745

reply all(5)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-17 10:07:01

     UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"xxx" bundle:nil];
     SCMainViewController *vc = [storyboard instantiateViewControllerWithIdentifier:NSStringFromClass([SCMainViewController class])];
     [self.navigationController pushViewController:vc animated:YES];

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-17 10:07:01

    You can jump and feel your Stroyboard 上相对应的 ViewController 没有关联 Class - SCMainViewController.

    reply
    0
  • 習慣沉默

    習慣沉默2017-05-17 10:07:01

    id loadViewControllerFromStoryboard(NSString *name,NSString *identifier)
    {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:name bundle:nil];
        UIViewController *vc = nil;
        
        if (identifier == nil)
        {
            vc = [storyboard instantiateInitialViewController];
        }
        else
        {
            vc = [storyboard instantiateViewControllerWithIdentifier:identifier];
        }
        
        if ([vc isKindOfClass:[UIViewController class]]) {
            return vc;
        }
        return nil;
    }

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-17 10:07:01

    First fill in the StoryBoard ID in storyBoard

    Then load the viewController using the following code:

    UIViewController *listController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"listViewController"];

    reply
    0
  • 高洛峰

    高洛峰2017-05-17 10:07:01

    1. Binding class

    2.push

    reply
    0
  • Cancelreply