iphone - 如何从模型 segue TableView Controller 中获取数据?

标签 iphone ios uitableview uistoryboardsegue

我有 ViewController执行模型类型 segue 和另一个 UITableViewController来自底部,它在 UITableView 中有类别. I want that when any of the category selected it must pass back some data to the sender controller

最佳答案

将第一个 View Controller 设置为模态 UITableViewController 的自定义委托(delegate),可以引用UITableViewControllerUITableView在此方法的第一个 View Controller 中,如下所示:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    if([[segue identifier] isEqualToString:@"tableviewController"]){
         MyTableViewController *myTableViewController = (MyTableViewController *)[segue      destinationViewController];

         myTableViewController.delegate = self;
     }
} 

您将需要在表格 View Controller 上设置委托(delegate)回调等和属性。如果您还不知道,应该有很多关于如何做到这一点的指南,这里有一个

How do I set up a simple delegate to communicate between two view controllers?

关于iphone - 如何从模型 segue TableView Controller 中获取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12744003/

相关文章:

iphone - 从 Flickr 加载 Retina 显示图像(使用 Three20 TTThumbnailViewController)

ios - webVIew.request.URL 在 didFailLoadWithError : is the previous URL not the failed URL

ios - 自定义子类中的变量不会保存/不会从核心数据加载

ios - 如何为空白区域设置 UITableView 背景?

ios - scrollViewDidScroll 方法不引用 TableView 中的所有 ScrollView

iphone - 这是 UIImage 的有效使用吗?

iphone - 数字布局在安全的 UITextField 中不粘?

ios - didSelectRowAt indexPath 未被调用

html - 通过根据 html 标签调整单元格大小,使用 UITextView 在 UITableViewCell 中显示 html [不是 UILabel!]

ios - 在应用启动时显示介绍视频