码迷,mamicode.com
首页 > 其他好文 > 详细

storyboard传值方式

时间:2016-03-11 22:08:22      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:

通过segue传值 在storyboard设置segue的Identifier
 
segue是连接两个视图控制器交互的线
sender是触发这个方法执行的对象,比如是单击tableView上的cell跳到下一界面  那么这个cell就是sender
//此方法在表视图控制器.m文件中最下面
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.
   //将当前位置的jid赋值给要跳转的视图控制器的的jid属性 if ([segue.identifier isEqualToString:@"push"]) { UITableViewCell *cell = sender; ChatTableViewController *chatVC = segue.destinationViewController;//跳转的下一界面 NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];//获取位置信息 XMPPJID *jid = self.dataArray[indexPath.row];//根据位置信息找到数据 chatVC.jid = jid; } }

  

storyboard传值方式

标签:

原文地址:http://www.cnblogs.com/dabaomo/p/5267263.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!