您好,欢迎来到九壹网。
搜索
您的当前位置:首页Storyboard使用TableView进行页面跳转传值

Storyboard使用TableView进行页面跳转传值

来源:九壹网

场景

StoryBoard中

A 界面 TableView

B界面 明细页面

A & B通过Cell的Section Action事件进行页面跳转。


Controller中

table delegate

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
      
}
    
override func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? {
        
        return indexPath
}


storyboard页面跳转回调

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
      // Get the new view controller using segue.destinationViewController.
      // Pass the selected object to the new view controller.
        
      destinationCtr = segue.destinationViewController as? FriendViewController
}


通过debug发现prepareForSegue:调用时机在willSelect 和didSelect之间,所以我们可以选择在willSelect方法中获取值,然后在prepareForSegue中传到下个界面,或者在prepareForSegue中获取到下个界面的controller,然后在didSelect中将选中的值赋给controller

转载于:https://my.oschina.net/lavzchen/blog/484625

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- 91gzw.com 版权所有 湘ICP备2023023988号-2

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务