1
我已经做了的UITextField我实现委托检测,如果编辑应该开始:的iOS UIPickerView不显示
- (BOOL) textFieldShouldBeginEditing:(UITextField *)textField{
if(textField.tag == TEXT_FIELD_UNION){
self.isUnionPickerActive = YES;
[self.textFieldUnionId setInputView:self.pickerUnionId];
}
return YES;
}
所以编辑应该开始的,而不是键盘我想表明我UIPickerView的时候。
- (UIPickerView *) pickerUnionId {
if(_pickerUnionId){
_pickerUnionId = [[UIPickerView alloc] init];
[_pickerUnionId setDataSource:self];
[_pickerUnionId setShowsSelectionIndicator:YES];
}
return _pickerUnionId;
}
但它没有显示;)我在这里做错了什么?这适用于一个的UIDatePicker,但我需要一个又一个
的问题在这里:
- (NSArray *) unions{
if(!_unions) _unions = [[NSArray alloc] initWithObjects:@"Item 1", @"Item 2", @"Item 3", @"Item 4", @"Item 6", nil];
return _unions;
}
错过了 “!”所以我是新手;)
尝试设置UIPickerView帧 – Mutawe
不必这样做 – Haagenti