Search code examples
iosiphoneuinavigationcontrolleruistoryboardsegue

rightBarButtonItem add segue


I want to add a segue and use the functionality of 'prepareForSegue' function. But can anyone please guide how to connect to a new controller from the rightbarbuttomitem of navigation view controller item? In the storyboard, i want to know how to connect the same, please guide and oblige.


Solution

  • Just press ctrl+mouse and drag & drop it to the new view controller. It'll ask for 'Action Segue', use 'push', and name it(e.g 'Test Segue')

    and in the view controller class, just define

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        if([segue.identifier isEqualToString:@"Test Segue"]) {
           // Do initializations
        }
    }