这个源码案例是一个日期时间的选择器,源码DVDatePickerTableViewCell,DVDatePickerTableViewCell是使用Swift写的cell。可以在tebleView中提供一个日期时间的选择器,并持续显示在Cell上。
效果图:
<ignore_js_op>
使用方法:
DVDatePickerTableViewCell想平常使用cell那样使用即可。
var cells:NSArray = []
cells = [[DVDatePickerTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: nil)]]
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
return cells[indexPath.section][indexPath.row] as UITableViewCell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
var cell = self.tableView(tableView, cellForRowAtIndexPath: indexPath)
if (cell.isKindOfClass(DVDatePickerTableViewCell)) {
var datePickerTableViewCell = cell as DVDatePickerTableViewCell
datePickerTableViewCell.selectedInTableView(tableView)
}
self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
}