xcode 如何将表视图控制器单元格链接到另一个视图?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14921787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I link a table view controller cell to another view?
提问by user2069876
What I want is when you click on any cell in the table you go to a view. I also need for each different cell you click on the view you get taken to has different strings. However I don't know
我想要的是当您单击表格中的任何单元格时,您将转到一个视图。我还需要您点击视图的每个不同单元格都有不同的字符串。然而我不知道
- how to link a table cell to another view when you press it
- how do you change the detail view controller for each different cell you click on.
- 按下时如何将表格单元格链接到另一个视图
- 您如何为您单击的每个不同单元格更改详细信息视图控制器。
Thank-you for trying to help me.
谢谢你试图帮助我。
回答by user2069876
You need to get a better understanding of how to use storyboards and then how to customize UItableView
cells as per your needs.
您需要更好地了解如何使用故事板以及如何根据UItableView
需要自定义单元格。
You can know more about using storyboards in this link
您可以在此链接中了解有关使用故事板的更多信息
And after you get familiar with storyboards, you should think about customizing UItableView
cells , you can customize as per your needs.
熟悉storyboards后,你应该考虑自定义UItableView
单元格,你可以根据自己的需要进行自定义。
See this link, will surely help you.
看到这个链接,一定会帮助你。
Please go through these well before you copy paste any code.
在复制粘贴任何代码之前,请仔细阅读这些内容。
回答by blub
create a segue from the tableview to the detail view controller
use
prepareForSegue:sender:
and something like
创建从 tableview 到详细视图控制器的 segue
使用
prepareForSegue:sender:
和类似的东西
[segue.destinationViewController setDetail:[self detailForIndexPath:[self.tableView indexPathForSelectedRow]]];
inside that method
[segue.destinationViewController setDetail:[self detailForIndexPath:[self.tableView indexPathForSelectedRow]]];
在那个方法里面
Just google segue UITableView or something like that for some examples / step-by-step tutorials / ..
对于一些示例/分步教程/..
(There are other options too, like using the UITableView delegate mehthod tableView: tableViewdidSelectRowAtIndexPath:
, but I think the segueing one is the easiest to understand)
(还有其他选项,比如使用 UITableView 委托方法tableView: tableViewdidSelectRowAtIndexPath:
,但我认为 segueing 是最容易理解的)