我最近使用Xcode 8.0將項目轉換爲Swift 3,並且我在函數上遇到了一個錯誤,我不太明白。在這些線路上:Swift 3.0 UITableViewDelege Objective-c方法與需求選擇器不匹配
extension HomeTableViewController : UITableViewDelegate {
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
}
}
要解決此錯誤時,Xcode告訴我,就在方法前加@objc(tableView:commitEditingStyle:forRowAtIndexPath:)
。
好了,它的工作原理,但我不知道爲什麼它只是需要這種方法。
Xcode不需要在我的tableView:heighForHeaderInSection
前添加@objc的東西,但我沒有看到在此方法和tableView:commitEditingStyle:forRowAtIndexPath:
之間UITableViewDelegate
的任何差異。
那麼,知道爲什麼這是tableView:commitEditingStyle:forRowAtIndexPath
方法的強制性?
在此先感謝!
我有同樣的問題@objc(tableView:heightForRowAtIndexPath :)方法。不知道爲什麼 – Maiaux