【发布时间】:2014-11-09 19:09:34
【问题描述】:
当我尝试将委托和数据源设置为 UIViewController 时,所有在 UITableViewController 中运行良好的函数都被检测为错误。
func numberOfSectionsInTableView(tableView: UITableView!) -> Int {
// #warning Potentially incomplete method implementation.
// Return the number of sections.
return 1
}
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete method implementation.
// Return the number of rows in the section.
return 10
}
错误是
FirstViewController.swift:11:1: Type 'FirstViewController' does not conform to protocol 'UITableViewDataSource':
UIKit.UITableViewDataSource:2:48: Protocol requires function 'tableView(_:numberOfRowsInSection:)' with type '(UITableView, numberOfRowsInSection: Int) -> Int'
FirstViewController.swift:29:10: Candidate has non-matching type '(UITableView!, numberOfRowsInSection: Int) -> Int'
UIKit.UITableViewDataSource:3:48: Protocol requires function 'tableView(_:cellForRowAtIndexPath:)' with type '(UITableView, cellForRowAtIndexPath: NSIndexPath) -> UITableViewCell'
FirstViewController.swift:29:10: Candidate has non-matching type '(UITableView!, numberOfRowsInSection: Int) -> Int'
这是 Xcode 6(不是测试版)。 UIViewController 中是否不再支持表格视图委托?
(相同的代码在 Xcode 6 Beta 5 中有效,但在 Xcode 6 GM 中无效。)
【问题讨论】:
标签: xcode uitableview uiviewcontroller swift xcode6