简体   繁体   English

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

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

I am working on a project where there arises a situation that I want to move from one table view controller to another table view controller 我正在一个项目中发生可能要从一个表视图控制器移动到另一表视图控制器的情况

(ie) when I click on any cell in the table view it should go to another table view.I also need for each different cell you click on the table view you get taken to another table view.i don't know how to do it (即)当我单击表格视图中的任何单元格时,应该转到另一个表格视图。我还需要为每个不同的单元格单击表格视图,然后转到另一个表格视图。我不知道该怎么做它

1.how to link the two table view controller 1.如何链接两个表视图控制器

2.what would be the code for that 2.那是什么代码

please help me 请帮我

make your first table, add prototype cell, from that cell create a segue to your second table, after that write this code : 编写您的第一个表,添加原型单元格,从该单元格创建一个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.
                }}

This is just the concept. 这只是概念。 if you want a more clear answer try posting your complete code. 如果您想获得更清晰的答案,请尝试发布完整的代码。 If you just want the logic, here it is. 如果您只想要逻辑,这里就是。 This is a link to similar project which has a table and when any row is clicked , it will pass you to another view, which is Web view related to that specific row , every row has a different link, though it is not a Table view, but you can get the concept at least. 这是指向具有表的相似项目的链接 ,当单击任何行时,它将带您转到另一个视图,该视图是与该特定行相关的Web视图,尽管不是表视图,但每一行都有不同的链接。 ,但至少可以理解这个概念。

The model for a table view is an array.You can try something like this. 表格视图的模型是一个数组。您可以尝试类似的方法。

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];

Hope this helps.... 希望这可以帮助....

暂无
暂无

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

相关问题 iOS无法从表视图控制器导航到另一个 - IOS can't navigate from a table view controller to another one 如何从一个视图控制器导航到另一视图控制器? - How to navigate from one view controller to another view controller? 如何在 Swift 中以编程方式从一个控制器导航到另一个视图控制器? - How to navigate from one controller to another View Controller programmatically in Swift? 如何将信息从一个视图控制器中的表视图单元传递到另一视图控制器? - How do I pass information from a table view cell in one view controller to another view controller? 如何使用 Swift 从一个视图控制器导航到另一个视图控制器 - How to Navigate from one View Controller to another using Swift 如何从popoverpresentation视图控制器导航到另一个视图控制器 - How to navigate from popoverpresentation view controller to another view controller 从一个视图 controller 到另一个视图显示表格视图单元格的问题 - Issues displaying a table view cell from one view controller to another 如何在按钮单击时从一个视图控制器导航到另一个视图控制器? - How to navigate from one view controller to another view controller on button click? 如何从一个视图控制器导航到另一个 - How to navigate From one view controller to other 将json ID从一个表视图控制器传递到Swift 3中的另一个表视图控制器 - pass json id from one table view controller into another table view controller in swift 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM