iphone - performSegueWithIdentifier if语句不起作用

原文 标签 iphone objective-c ios uitableview

我有6个差异表,当选择其中一个表中的行时(在regionsFirstTable中,哪一个表很重要),我希望它们执行顺序。 regionFirstTable的代码可以正常工作,但对于其他部分则不行,因为segue不能正常工作。我知道它太乱了,但是答案应该放在表面上。

- (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
}
} 


提前致谢!

附言我所有的表只有一个indexPath.section

最佳答案

第一个{之后似乎有太多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
} 

关于iphone - performSegueWithIdentifier if语句不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10689122/

相关文章:

iphone - iOS:UIImageView示例代码

android - iPhone或Android设备是临时生成的还是“常规”生成的移动热点?

ios - 使用Instagram API将我的照片上传到Instagram

ios - 可以禁用并突出显示iOS导航栏按钮项吗?

iphone - 是否可以从 Nib 访问UITableView的ScrollView代码?

ios - "Please set up mail account in order to send email"Swift 中的错误

iphone - 如何使用分页加载我的 tableview?

iphone - touchesEnded :withEvent: not being called from my UIView, 位于 UITableView 之上

objective-c - 为什么NSString会“忘记”它的含义?

ios - 开关错误 : Expected member name or constructor call - what's wrong?