[英]Show UiPickView on Tap textfield inside Custom Cell dynamic UITableView
我需要在Tableview中显示一个自定义的uidropdown,但是在iOS中使用UIPickerView而不是dropdown.Table视图是动态生成的,取决于服务器的输入数据,它对于UiTextFields很好用,但是我不能使用它显示UIPickerView.Plese指导我如何解决此问题。谢谢。
Write delegate method of UItextFiled
编写UItextFiled
委托方法
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
[textField resignFirstResponder];
[self setupPicker];
}
and call setupPicker
method 并调用setupPicker
方法
-(void)setupPicker
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Set alarm time" message:@"\n\n\n\n\n\n\n\n" delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
[alert show];
alert.bounds = CGRectMake(0, 10, 284, 279);
if(!self.datePicker)
{
self.Picker = [[UIPickerView alloc] init];
self.Picker.frame = CGRectMake(20, 45.0, 240.0, 150.0);
self.picker.delegate = self;
self.picker.dataSource = self;
}
[alert addSubview:self.Picker];
}
Above code for display picker view when you click on UITextFiled
and UIPickerView
display on AlertView. 当您在AlertView上单击UITextFiled
和UIPickerView
显示时,上面的代码将显示选择器视图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.