【发布时间】:2016-02-16 21:22:57
【问题描述】:
Code and errors Continued on the code and one more errors!
嗨,我是 Xcode swift 的新手。到目前为止,我一直做得很好,除了尝试从 8.2 开始遵循某人的教程,并且我遇到了这些我最难理解的错误。谁能解释这些错误的含义,也许,也许只是如何解决它们?
我已经编辑了我的帖子,链接的项目不能超过 2 个。
【问题讨论】:
Code and errors Continued on the code and one more errors!
嗨,我是 Xcode swift 的新手。到目前为止,我一直做得很好,除了尝试从 8.2 开始遵循某人的教程,并且我遇到了这些我最难理解的错误。谁能解释这些错误的含义,也许,也许只是如何解决它们?
我已经编辑了我的帖子,链接的项目不能超过 2 个。
【问题讨论】:
您需要在您的其他@IBOutlets 之前声明您的tableView,因为您正在使用UIViewController 并将tableView 放在它的视图中。目前UIViewController 也不知道你指的是什么tableView。
@IBOutlet var tableView: UITableView!
然后在界面构建器中将其链接起来,就像您对其他 @IBOutlets 所做的那样。确保将tableView 的delegate 和dataSource 属性也链接回视图控制器。
要执行后者,请在选择 tableView 后,选择 Connections Inspector 区域,如下图所示,然后将它们连接回您的 UIViewController。
【讨论】:
@IBOutlet 引用连接到tableView?
就我而言,我使用过:
@IBOutlet private weak var tableView: UITableView!
并在扩展方法中使用 tableView。
我已将private 更改为fileprivate,并且错误消失了。
【讨论】:
它在 Swift 4 中
let iPath = NSIndexPath(row: self.TableView.numberOfRows(inSection: 0)-1,
section: self.messageTableView.numberOfSections-1)
self.TableView.scrollToRow(at: iPath as IndexPath,
at: UITableViewScrollPosition.bottom,
animated: true)
【讨论】: