iOS开发的代理类中willXXXXX和didXXXXX的区别和分别什么时候用

Code&Ocean 2016-03-26 04:59:14
一些代理的中经经常出现willXXXXXX 和didXXXXX,如
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath?
不太明白区别,应该在什么时候用了
...全文
545 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
网易云捕 2016-07-08
  • 打赏
  • 举报
回复
will(相当于before) -> UI动作发生 -> did(相当于after)
网络咖啡 2016-07-06
  • 打赏
  • 举报
回复
will是将要执行某个操作,相当于before,did是已经执行某个操作,相当于after,可以根据需要决定使用哪个回调方法
头发还没秃a 2016-03-28
  • 打赏
  • 举报
回复
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) //已经选中的时候 func tableView(tableView: UITableView, willSelectRowAtIndexPath indexPath: NSIndexPath) -> NSIndexPath? //将要选中的时候

1,420

社区成员

发帖
与我相关
我的任务
社区描述
Swift,苹果于2014年WWDC(苹果开发者大会)发布的新开发语言,可与Objective-C共同运行于MAC OS和iOS平台,用于搭建基于苹果平台的应用程序。
swift 技术论坛(原bbs)
社区管理员
  • Swift
  • 网罗开发
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧