カスタム ビューを UITextField の inputView プロパティに設定したいと考えています。(基本的に、UIPickerView の selectionIndicator に UILabel を追加したいのですが、もっと簡単な方法が見つからなかったので...) UIPickerView を inputView として設定すると、すべて正常に動作します。しかし、UIView を inputView として設定すると、UITextField が firstResponder になったときに表示されません。ここで誰か私に説明がありますか?
これは機能します:
UITextField* field = [[UITextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)];
// configuration of field
UIPickerView* pickerView = [[UIPickerView alloc] initWithFrame:field.inputView.frame];
pickerView.delegate = self;
pickerView.dataSource = self;
pickerView.showsSelectionIndicator = YES;
field.inputView = pickerView;
これはしません:
UITextField* field = [[UITextField alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 30.0)];
// configuration of field
UIView* view = [[UIView alloc] initWithFrame:field.inputView.frame];
view.backgroundColor = [UIColor redColor];
field.inputView = view;