| 這個源碼案例是一個日期時間的選擇器,源碼DVDatePickerTableViewCell,DVDatePickerTableViewCell是使用Swift寫的cell。可以在tebleView中提供一個日期時間的選擇器,并持續顯示在Cell上。 效果圖:
使用方法: 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) } |
|
新聞熱點
疑難解答