Call a view controller programatically using storyboard id iOS

后端 未结 3 827
离开以前
离开以前 2021-01-22 00:10

What I Want?

  • In MainViewController I open a view from a xib programmatically. This xib view contains a UIButton. The xib opens successf
3条回答
  •  伪装坚强ぢ
    2021-01-22 01:02

    Check these things

    Check the identifier of the viewcontroller, if it is the same that you mentioned in storyboard

    Make sure that your view object is not nil. Set a breakpoint on that line and on the debug area at the bottom see whether the object is not nil. If it is nil then problem lies in the storyboard connection

    If your current viewcontroller is not launched from storyboard then get storyboard object like this :

    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    UIViewController * feedbackVC = [storyboard   instantiateViewControllerWithIdentifier:@"FeedBackView"] ;
    [self presentViewController:feedbackVC animated:YES completion:nil];
    

提交回复
热议问题