·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> IOS开发 >> 日期时间的选择器ios源码

日期时间的选择器ios源码

作者:佚名      IOS开发编辑:admin      更新时间:2022-07-23

这个源码案例是一个日期时间的选择器,源码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) 
    }