문제

I'm trying to recreate a small iOS app that utilized nib files. I'm trying to replace the following line of code

 self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

with:

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController* viewController = [sb instantiateViewControllerWithIdentifier:@"viewController"];    self.window.rootViewController = self.    viewController;

I'm getting the following error: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'viewController''

I got the latter code from a previous Stack Overflow question on a similar topic. Can someone please advise on what the issue I'm having is and how to proceed?

도움이 되었습니까?

해결책

You need to name the view controller in your storyboard by giving it a storyboard id. I typically try to use something memorable like the name of the view controllers class so I don't have to look it up.enter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top