我有一个 UIPickerView 在选择文本字段时出现:
-(void) showPicker
{
[self.genere resignFirstResponder];
pickerGenero = [[UIPickerView alloc] initWithFrame:CGRectMake(0,215,320,0)];
pickerGenero.delegate = self;
pickerGenero.dataSource = self;
pickerGenero.showsSelectionIndicator = YES;
[self.parentViewController.tabBarController.view addSubview:pickerGenero];
pickerGenero=nil;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
return [genreArray count];
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 1;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
self.genere.text =[genreArray objectAtIndex:row];
[self.pickerGenero removeFromSuperview];
}
但是在选择行时不会被删除。文本字段会使用选定的值进行更新,但不会删除选取器视图。我尝试将 .setideen=True 用作试用版,但它也不起作用。
非常感谢