Navigating Backwards through a UINavigationController Error

前端 未结 1 851
梦毁少年i
梦毁少年i 2021-01-13 05:32

I have a UINavigationController which goes into a ViewController that loads data. This ViewController then segues to TabViewController. This TabViewController has two tabs,

相关标签:
1条回答
  • 2021-01-13 06:06

    I have a table view and a search bar controller on it.I created push segue on table view cell and performed push on selecting search item via search controller programatically.When navigated back exception fired.This exception happens when you perform same segue twice at a time.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:
    (NSIndexPath*)indexPath
    {
    if (tableView == self.searchDisplayController.searchResultsTableView)
    {
    
        [self performSegueWithIdentifier:@"showDetail"sender:self];
    }
    }
    

    Since it was performing same segue twice one for table view cell selection created in storyboard and another for search result cell selection. So check when to perform segue

    - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
    {
    if (self.tableView == self.searchDisplayController.searchResultsTableView)
    {
    
        [self performSegueWithIdentifier:@"showDetail"sender:self];
        return YES;
    }
    
    return NO;
    }
    

    This worked perfectly.

    0 讨论(0)
提交回复
热议问题