Combining custom actions with segues in table cell selections.

Triggering custom actions like open an URL with segues in storyboards is not quite obvious in the first attempt.
The trick is to drag a segue from the cell to the view controller icon on the bottom of the scene. This segue is pointing to the same scene as seen in the image below:

Screen Shot 2014-05-19 at 12.40.04

Now just set an identifier for the segue and trigger the correct action according to the identifier in the method -prepareForSegue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        // some other code
    } else if ([[segue identifier] isEqualToString:@"openLink"]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.apple.com"]];
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *