在 tableviewcell 内使用 UITableview 执行 segue [英] perform segue with UITableview inside a tableviewcell

查看:22
本文介绍了在 tableviewcell 内使用 UITableview 执行 segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

供参考:

TABLEVIEW(1 部分 - 3 行)在每一行中,我都有一个包含另一个 tableview 的自定义单元格.

TABLEVIEW (1 section - 3 rows) in each row I have a custom cell that contains another tableview.

自定义单元格内的 tableview 子类化为 uitableviewcell在那里我实现了我所有的委托,比如 cellforrow 等,并且 UITableView 单元格中表格视图的文件所有者是我的 UIViewController.

the tableview inside the custom cell is subclassed with a uitableviewcell where I implement all of my delegates, like cellforrow etc. etc., and the file owner of the table view inside the UITableView cell is with my UIViewController.

如何使用子类 UITableViewCell 执行转场?

How can I perform segue using the subclass UITableViewCell?

有什么想法可以做什么吗?

Any ideas what to do?

注意:我使用 UITableViewCell 上的 tableview 作为子类.

NOTE: I am using the tableview on the UITableViewCell as subclass.

推荐答案

control从视图控制器拖到视图控制器

control drag From View Controller to View Controller

您需要为您的转场提供一个标识符:

You will need to give an identifier to your segue:

执行转场:

didSelectRowAtIndexPath

 -(void)tableView:(UITableView *)tableView 
                            didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
   [self performSegueWithIdentifier:@"yourSegue" sender:sender];
 }

现在是这样,如果您需要将一些数据传递给该视图控制器,这将只执行转场.然后你必须实现以下 segue 委托:

Now here is the thing, this will just perform the segue, if you ever needed to pass some data to that view controller. Then you have to implement the following segue deleguate:

prepareForSegue

 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"yourSegue"])
    {  
       //pass data here
    }
}

这篇关于在 tableviewcell 内使用 UITableview 执行 segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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