0

我有 6 个不同的表,当其中一个表中的行被选中时(在 regionFirstTable 中重要的是哪个表),我希望它们执行一个 segue。regionFirstTable 的代码工作正常,但至于另一部分它没有 - segues 只是不工作。我知道这太混乱了,但答案应该是表面上的。

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

if (tableView == self.regionsFirstTable) {
    {     if (indexPath.row==0)
        if (indexPath.section==1) {
            [self performSegueWithIdentifier:@"toAfricanFS" sender:indexPath];
        } else {
            [self performSegueWithIdentifier:@"toAfricanFS" sender:indexPath];
        }
        if (indexPath.row==1)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toAsiaFS" sender:indexPath];

            } else {
                [self performSegueWithIdentifier:@"toAsiaFS" sender:indexPath];
            }
        if (indexPath.row==2)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toEuropeFS" sender:indexPath];

            } else {
                [self performSegueWithIdentifier:@"toEuropeFS" sender:indexPath];
            }
        if (indexPath.row==3)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toLatinFS" sender:indexPath];
            } else {
                [self performSegueWithIdentifier:@"toLatinFS" sender:indexPath];
            }
        if (indexPath.row==4)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toNorthAmericaFS" sender:indexPath];
            } else {
                [self performSegueWithIdentifier:@"toNorthAmericaFS" sender:indexPath];
            }
    } //Dealing with the first UITableView, it works

    if (tableView == self.africaFirstTable) {
        [self performSegueWithIdentifier:@"fromAfricatoDone" sender:indexPath];
    } 
    if (tableView == self.asiaFirstTable) {
        [self performSegueWithIdentifier:@"fromAsiatoDone" sender:indexPath];
    } 
    if (tableView == self.europeFirstTable) {
        [self performSegueWithIdentifier:@"fromEuropetoDone" sender:indexPath];
    }
    if (tableView == self.latinAmericaFirstTable) {
        [self performSegueWithIdentifier:@"fromLatintoDone" sender:indexPath];
    } 
    if (tableView == self.northAmericaFirstTable) {
        [self performSegueWithIdentifier:@"fromNorthAmericatoDone" sender:indexPath];
    } //This whole thing is not working as it should be
}
} 

提前致谢!

PS我所有的表只有一个 indexPath.section

4

1 回答 1

1

看起来你在 first 之后有太多{s if,所以你的所有检查if ( tableView == self.northAmericaFirstTable)都没有命中,因为它都嵌套在if (tableView == self.regionsFirstTable)块中

编辑:

这是固定的代码,理论上

- (void)tableView:(UITableView *)tableView 
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

if (tableView == self.regionsFirstTable) {
     if (indexPath.row==0)
        if (indexPath.section==1) {
            [self performSegueWithIdentifier:@"toAfricanFS" sender:indexPath];
        } else {
            [self performSegueWithIdentifier:@"toAfricanFS" sender:indexPath];
        }
        if (indexPath.row==1)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toAsiaFS" sender:indexPath];

            } else {
                [self performSegueWithIdentifier:@"toAsiaFS" sender:indexPath];
            }
        if (indexPath.row==2)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toEuropeFS" sender:indexPath];

            } else {
                [self performSegueWithIdentifier:@"toEuropeFS" sender:indexPath];
            }
        if (indexPath.row==3)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toLatinFS" sender:indexPath];
            } else {
                [self performSegueWithIdentifier:@"toLatinFS" sender:indexPath];
            }
        if (indexPath.row==4)
            if (indexPath.section==1) {
                [self performSegueWithIdentifier:@"toNorthAmericaFS" sender:indexPath];
            } else {
                [self performSegueWithIdentifier:@"toNorthAmericaFS" sender:indexPath];
            }
    } //Dealing with the first UITableView, it works

    if (tableView == self.africaFirstTable) {
        [self performSegueWithIdentifier:@"fromAfricatoDone" sender:indexPath];
    } 
    if (tableView == self.asiaFirstTable) {
        [self performSegueWithIdentifier:@"fromAsiatoDone" sender:indexPath];
    } 
    if (tableView == self.europeFirstTable) {
        [self performSegueWithIdentifier:@"fromEuropetoDone" sender:indexPath];
    }
    if (tableView == self.latinAmericaFirstTable) {
        [self performSegueWithIdentifier:@"fromLatintoDone" sender:indexPath];
    } 
    if (tableView == self.northAmericaFirstTable) {
        [self performSegueWithIdentifier:@"fromNorthAmericatoDone" sender:indexPath];
    } //This whole thing is not working as it should be
} 
于 2012-05-21T16:55:45.680 回答