gpt4 book ai didi

iphone - PerformSegueWithIdentifier if 语句不起作用

转载 作者:行者123 更新时间:2023-11-29 04:38:49 26 4
gpt4 key购买 nike

我有 6 个不同的表,当选择其中一个表中的行时(在 RegionFirstTable 中,哪个表很重要),我希望它们执行 Segue。 regionsFirstTable 的代码工作正常,但至于其他部分却不行——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
}
}

提前致谢!

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

最佳答案

看起来你有太多{在您的第一个 if 之后,所以您对 if ( tableView == self.northAmericaFirstTable) 的所有检查没有命中,因为它全部嵌套在 if (tableView == self.regionsFirstTable) 中 block

编辑:

理论上这是固定代码

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com