【问题标题】:tableView(cellForRowAtIndexPath) vs. tableView.cellForRowAtIndexPath()?tableView(cellForRowAtIndexPath) 与 tableView.cellForRowAtIndexPath()?
【发布时间】:2015-12-26 19:12:01
【问题描述】:

这两种方法看起来非常相似,我不确定我是否完全理解如何知道要调用哪一种。

我这样认为是对的吗

tableView(cellForRowAtIndexPath) 

是 tableView 发送到它的 dataSource 而,

tableView.cellForRowAtIndexPath() 

控制器发送给tableView的是什么?

【问题讨论】:

    标签: ios uitableview cocoa-touch


    【解决方案1】:

    让我们以标准的 Swift 方式编写这些方法选择器。

    选择器tableView(_:cellForRowAtIndexPath:)UITableViewDataSource 协议的一部分。表格视图会针对每个可见行向其dataSource 发送一次此消息。

    选择器cellForRowAtIndexPath(_:)UITableView 类的一部分。您可以将其发送到表格视图以向其询问 可见 行的单元格。如果该行可见,则表格视图将返回该单元格。否则,表格视图返回 nil。

    【讨论】:

    • 好的,我想我明白了。看到他们像你一样写出来很有帮助。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-23
    • 1970-01-01
    相关资源
    最近更新 更多