I have this code that lets me create a custom UIBarButton which is inside my viewDidLoad.
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleDone
target:nil
action:nil];
self.navigationItem.rightBarButtonItem = doneButton;
Now, I want this method below to be called when the UIBarButton is pressed so that a segue to the next view controller will be done.
- (void) didPressDone {
PointsResultsViewController *pointsResults = [self.storyboard instantiateViewControllerWithIdentifier:@"resultsPointsVC"];
[self.navigationController pushViewController:pointsResults animated:YES];
}
I’ve done some research regarding this. However the ones I saw were all about dragging a UIBarButton to the ViewController from the Object Library then just wire it up to the next VC, have the method prepareForSegue, done, simple as that. In my case, it’s quite different.
Advice please 🙂
You can set the target to self and the action to your didPressDone selector:
The selector should have a signature like this: