How to “cancel” a UIStoryBoardSegue

前端 未结 9 1836
小蘑菇
小蘑菇 2020-12-23 21:40

Does anyone know how to \"stop\" a segue transition conditionally:

My table view cells represent products which can be viewed in a drill-down \"detail\" view... or

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-23 22:09

    If you are targeting iOS 6 or greater, then my knowledge of the cleanest way to do this is the following:

    -(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
    {
        if([identifier isEqualToString:@"show"])
        {
            NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
            Blocco *blocco = [self.fetchedResultsController objectAtIndexPath:selectedRowIndex];
            return [blocco meetRequiredConditions];
        }
        return YES;
    }
    

    Where there is a method

    -(BOOL) meetsRequiredConditions;
    

    Defined on your Blocco class returns YES if the "couple of things" which permit a drill-down are valid.

提交回复
热议问题