PrepareForSegue没有功能

时间:2014-04-19 12:14:33

标签: objective-c ios7

我有一个包含8个部分的TableView。所有部分都有4个Row。对于每一行,都有一个详细视图控制器。

我现在在表格视图中添加了一个SearchBar。搜索工作,结果显示在搜索显示控制器中。

但我不能再进入详情视图了。它总是向我显示相同的DetailsView。

我在“PrepareForSegue”和“didSelectRowAtIndexPath”方法中做错了什么?

Methode“prepareForSegue”:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

if ([segue.identifier isEqualToString:@"BrasilienSegue"]) {
    BrasilienViewController *BVC = segue.destinationViewController;

    NSIndexPath *indexPath = nil;

    if ([self.searchDisplayController isActive]) {
        indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
        BVC.BrasilienLaenderLabel = [self.searchCountriesArray objectAtIndex:indexPath.row];

    } else {
        indexPath = [self.tableView indexPathForSelectedRow];
        BVC.BrasilienLaenderLabel = [self.listeDerNationen objectAtIndex:indexPath.row];
    }
}

if ([segue.identifier isEqualToString:@"KroatienSegue"]) {
    KroatienViewController *KVC = segue.destinationViewController;

    NSIndexPath *indexPath = nil;

    if ([self.searchDisplayController isActive]) {
        indexPath = [self.searchDisplayController.searchResultsTableView indexPathForSelectedRow];
        KVC.kroatienLaenderLabel = [self.searchCountriesArray objectAtIndex:indexPath.row];

    } else {
        indexPath = [self.tableView indexPathForSelectedRow];
        KVC.kroatienLaenderLabel = [self.listeDerNationen objectAtIndex:indexPath.row];
    }
}

Methode“didSelectRowAtIndexPath”:

- (void)tableView:(UITableView *)tableView  didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self tableView: self.tableView  accessoryButtonTappedForRowWithIndexPath: indexPath];
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];

if (tableView == self.searchDisplayController.searchResultsTableView) {
    [self performSegueWithIdentifier: @"BrasilienSegue" sender: self];
}

if (tableView == self.searchDisplayController.searchResultsTableView) {
    [self performSegueWithIdentifier: @"KroatienSegue" sender: self];
}

}

0 个答案:

没有答案