我正在使用swift和以下代码在iphone中进行应用程序
override func viewDidLoad() {
//<#code#>
dateSet.userInteractionEnabled = true
let aSelector : Selector = "lblTapped"
let tapGesture = UITapGestureRecognizer(target: self, action: aSelector)
tapGesture.numberOfTapsRequired = 1
dateSet.addGestureRecognizer(tapGesture)
}
func lblTapped(){
// need to add datapicker UIView
}
答案 0 :(得分:0)
使用textfield inputView
将datepicker显示在底部。下面的示例代码
private func dateTextFieldSetup()
{
let datePickerView : UIDatePicker = UIDatePicker()
datePickerView.datePickerMode = UIDatePickerMode.Date
sampleTextfield.inputView = datePickerView
datePickerView.addTarget(self, action:#selector(CFTextField.handleDatePickerForSlectedText(_:)), forControlEvents: UIControlEvents.ValueChanged)
}
对于UILabel,inputView属性不可用。