来自UITableView中的节的条件目标视图控制器
TableView控制器中的代码
if ([segue.identifier isEqualToString:@"showListFiles"]) { NSIndexPath *ip = [self.tableView indexPathForSelectedRow]; if (ip.section == 0) { NSDictionary *currentBill = [[_response objectForKey:@"facturas_pendientes"] objectAtIndex:ip.row]; DkBPaymentViewController *pvc = [[DkBPaymentViewController alloc] init]; pvc = (DkBPaymentViewController *) segue.destinationViewController; pvc.setUp = currentBill; } else if(ip.section == 1){ DkBBillsFileTableViewController *ftvc = segue.destinationViewController; ftvc.filesList = [[[_response objectForKey:@"facturas_pagadas"] objectAtIndex:ip.row] objectForKey:@"archivos_facturas"]; } }
错误
-[DkBBillsFileTableViewController setSetUp:]: unrecognized selector sent to instance 0x85a3b00 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DkBBillsFileTableViewController setSetUp:]: unrecognized selector sent to instance 0x85a3b00'
你怎么做或根据表格部分的条款(第1节付款/第2节付费)条件转换到不同的视图控制器的最佳方法是什么?
细节
DkbPaymentViewController有它自己的xib,因为我不能让原型单元指向两个不同的
DkBBillsFileTableViewController是我声明的原始segue
非常感谢你提前,我相信在tableview中找到一个好的条件segue方法会让所有人受益。
您应该设置2个不同的单元格,每个单元格链接到不同的segues(因此它们具有不同的标识符),每个单元格指向不同的视图控制器。 这将使您的代码变得微不足道,防止类之间的混淆并按预期使用segue。
你可以以编程方式完成。 在故事板中,从视图控制器(而不是从单元格)中绘制两个segue。 然后在didSelectRowAtIndexPath
,执行以下操作:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == 0) { [self performSegueWithIdentifier:@"SegueForSection1" sender:indexPath]; } else if (indexPath.section == 1) { [self performSegueWithIdentifier:@"SegueForSection2" sender:indexPath]; } }