来自UITableView中的节的条件目标视图控制器 [英] Conditional Destination View Controller from Sections in UITableView

查看:99
本文介绍了来自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部分支付),你怎么做或者条件转换到不同视图控制器的最佳方式是什么?

How can you do or what is the best way to conditional segue to different view controllers based on the section of the section of the table (Section 1 To pay / Section 2 Paid) ?

详细信息

DkbPaymentViewController拥有自己的xib,因为我不能让原型单元格指向两个不同的

DkbPaymentViewController has it's own xib given that I can't make the prototype cell to point to two different

DkBBillsFileTableViewController是我声明的原始segue

DkBBillsFileTableViewController is the original segue that I declared

非常感谢你提前,我相信找到一个好方法在tableview中的条件segue会b enefit all。

Thank you so much in advance, I believe that to find a good method of conditional segue in a tableview would benefit all.

推荐答案

你应该设置2个不同的单元格,每个单元格链接到不同的segues(所以它们有不同的标识符),每个指向不同的视图控制器。这将使您的代码变得微不足道,防止类之间的混淆,并按预期使用segue。

You should setup 2 different cells, each linked to different segues (so they have different identifiers), and each pointing to different view controllers. This will make your code trivial, prevent confusion between classes and use segues as they are intended.

这篇关于来自UITableView中的节的条件目标视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆