0

私は6つの異なるテーブルを持っており、そのうちの1つの行が選択されたときに(regionFirstTableでどれが重要か)、それらにセグエを実行させたいと思っています。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
}
} 

前もって感謝します!

PSすべてのテーブルにはindexPath.sectionが1つしかありません

4

1 に答える 1

1

{最初の s の後に 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 に答える