Instantiate View Controller from Storyboard vs. Cr

2019-01-11 16:06发布

What is the functional difference between instantiating a View Controller from the storyboard and creating a new instance of it? For example:

#import "SomeViewController.h"

...

SomeViewController *someViewController = [SomeViewController new];

versus

#import "SomeViewController.h"

...

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];

SomeViewController *someViewController = [storyboard instantiateViewControllerWithIdentifier:@"SomeViewController"];

In either case, is someViewController effectively the same thing?

7条回答
时光不老,我们不散
2楼-- · 2019-01-11 16:52

another thing to check for is if the viewcontroller that's throwing the error has a storyboardIdentifier, you can check the storyboard xib file.

the identifier was missing in my case, the error stopped when i added it

查看更多
登录 后发表回答