繁体   English   中英

如何在xcode中从一个表视图控制器导航到另一个表视图控制器

[英]how to navigate from one table view controller to another table view controller in xcode

我正在一个项目中发生可能要从一个表视图控制器移动到另一表视图控制器的情况

(即)当我单击表格视图中的任何单元格时,应该转到另一个表格视图。我还需要为每个不同的单元格单击表格视图,然后转到另一个表格视图。我不知道该怎么做它

1.如何链接两个表视图控制器

2.那是什么代码

请帮我

编写您的第一个表,添加原型单元格,从该单元格创建一个segue到第二个表,然后编写以下代码:

     override func prepare(for segue: UIStoryboardSegue, sender: Any!)  
{
            if segue.identifier == "secondTable" //secondTable is identifier for Segue from prototype cell of 1st table to 2nd table.

            {
                let selectedRow = tableView.indexPathForSelectedRow?.row
                let viewController = segue.destination as! seocondViewController //secondViewController is your class for 2nd table.
               // If you also want to pass some data then add that code also.
                }}

这只是概念。 如果您想获得更清晰的答案,请尝试发布完整的代码。 如果您只想要逻辑,这里就是。 这是指向具有表的相似项目的链接 ,当单击任何行时,它将带您转到另一个视图,该视图是与该特定行相关的Web视图,尽管不是表视图,但每一行都有不同的链接。 ,但至少可以理解这个概念。

表格视图的模型是一个数组。您可以尝试类似的方法。

id anyPartOfMyM = [self.arrayA objectAtIndex:sIndexPath.row];
[self.arrayA removeObject:anyPartOfMyM];
[self.arrayB addObject:anyPartOfMyM];

// the simplest way to update the tables.
[self.tableViewA reloadData];
[self.tableViewB reloadData];

希望这可以帮助....

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM