Skip to content

A Swift5 library implement the UITableViewCell with a UIDatePicker or a UIPickerView.

License

Notifications You must be signed in to change notification settings

hijamoya/PickerViewCell

Repository files navigation

PickerViewCell

Language Swift 5.0
We provide two types of UITableViewCell:

1. DatePickerTableViewCell: when you make this cell `becomeFirstResponder`, it will invoke a UIDatePicker and then you can use the delegate function to get the value of the picker.

2. PickerTableViewCell: when you make this cell `becomeFirstResponder`, it will invoke a UIPickerView. You should specify your datasource and delegate.

Demo

Demo

Installation

pod 'PickerViewCell'

Useage

Make your table view cell be the cells we provided, and just invoke becomeFirstResponder when the cell is selected.

  override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)
    if let cell = tableView.cellForRow(at: indexPath) as? DatePickerTableViewCell {
      cell.delegate = self
      if !cell.isFirstResponder {
        _ = cell.becomeFirstResponder()
      }
    } else if let cell = tableView.cellForRow(at: indexPath) as? PickerTableViewCell {
      cell.delegate = self
      cell.dataSource = self
      if !cell.isFirstResponder {
        _ = cell.becomeFirstResponder()
      }
    }
  }

About

A Swift5 library implement the UITableViewCell with a UIDatePicker or a UIPickerView.

Resources

License

Stars

Watchers

Forks

Packages

No packages published