UITableview 内に複数の UIPickerViews と textfields を追加し、UIPickerViews を管理するためのさまざまな方法を使用するにはどうすればよいですか?
1 に答える
1
textField が選択されているときに pickerView を表示する必要がある場合は、pickerView を inputView として textField に追加する必要があります。
textField が多い場合は、textField の編集開始時に追加した方がよいでしょう。どの textField を表示するかを識別するには、各 textField にタグを付けます。
- (void)textFieldDidBeginEditing:(UITextField *)textField{
NSInteger tag = textField.tag;
//Conditionally check which textField you want to show picker
//Then call the method to add inputView to textField
[self addInputViewToTextField:textField];
}
- (void)addInputViewToTextField:(UITextField *)textField{
//Initialize pickerView
UIDatePicker *datePicker = ...
textField.inputView = datePicker;
}
textField が選択されたときに UIDatePicker を表示するサンプル プロジェクト。
于 2013-05-12T21:22:44.623 に答える