Reputation: 11
I use two buttons on right UIBARBUTTON by writing code in the method[ViewDidLoad].
I want to use +plus button to move to AddNameViewController but it results in a Fail[sigabrt]
.
I think the error is in the following code.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"AddNameViewController.m"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:YES completion:nil];
Upvotes: 1
Views: 3293
Reputation: 11
check this
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"AddNameViewController"];
[sfvc setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:sfvc animated:YES completion:nil];
and add identifier AddNameViewController in storyboard ID
Upvotes: 1
Reputation: 11
Sorry, I did not check carefully before asking. Because I tried many ways to improve it. Although, I change AddNameViewController.m
to AddNameViewController
,
It still show sigabrt.
Upvotes: 0
Reputation: 9012
Like Antonio said, you need the correct identifier for your view controller. The reason it crashes is because you get a nil view controller pointer back from the instantiateViewControllerWithIdentifier:
call and passing nil to presentViewController:animated:completion:
causes your crash.
Upvotes: 1
Reputation: 20410
Change this:
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"AddNameViewController.m"]
For this:
AddNameViewController *sfvc = [storyboard instantiateViewControllerWithIdentifier:@"AddNameViewController"]
You need the name of the View Controller, not the file.
Upvotes: 4