Ios 无法在Swift 1.2中的UITableViewDelegate方法中使用自定义TableViewCell类
我正在使用最新的XCode 6.3和Swift 1.2。我以前工作的旧代码不再工作了 我正在尝试在委托方法中使用自定义的Ios 无法在Swift 1.2中的UITableViewDelegate方法中使用自定义TableViewCell类,ios,xcode,uitableview,swift,custom-cell,Ios,Xcode,Uitableview,Swift,Custom Cell,我正在使用最新的XCode 6.3和Swift 1.2。我以前工作的旧代码不再工作了 我正在尝试在委托方法中使用自定义的UITableViewCell(SearchResultsTableViewCell) func tableView(tableView: UITableView, willDisplayCell cell: SearchResultsTableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { } 但是出现了这个错误
UITableViewCell
(SearchResultsTableViewCell
)
func tableView(tableView: UITableView, willDisplayCell cell: SearchResultsTableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
}
但是出现了这个错误消息
Objective-C method 'tableView:willDisplayCell:forRowAtIndexPath:' provided by method 'tableView(_:willDisplayCell:forRowAtIndexPath:)' conflicts with optional requirement method 'tableView(_:willDisplayCell:forRowAtIndexPath:)' in protocol 'UITableViewDelegate'
请帮忙。谢谢将单元格声明为UITableViewCell并向下转换为SearchResultsTableViewCell
func
tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let aSearchResultsTableViewCell = cell as! SearchResultsTableViewCell
}
将单元格声明为UITableViewCell并向下转换为SearchResultsTableViewCell
func
tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
let aSearchResultsTableViewCell = cell as! SearchResultsTableViewCell
}
不需要把手机放在那里。它可以与
UITableViewCell
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
//code
}
如果要访问,可以将UITableViewCell类型转换为所需的自定义单元格。无需将单元格放在那里。它可以与
UITableViewCell
func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
//code
}
如果您想访问,可以将UITableViewCell类型转换为所需的自定义单元格。I使用此功能,其工作正常。func tableView(tableView:UITableView,willDisplayCell-cell-cell-UITableViewCell,forRowAtIndexPath-indexath:nsindexath){…}我正在使用一个自定义单元格,我把它放在参数(SearchResultsTableViewCell)中,我正在使用它,并且工作正常。func tableView(tableView:UITableView,willDisplayCell-cell-cell-UITableViewCell,forRowAtIndexPath-indexath:nsindexath){…}我正在使用一个自定义单元格,并将其放入参数中(SearchResultsTableViewCell)