0

我需要在 Tableview 中显示自定义 uidropdown。但在 iOS 中使用 UIPickerView 而不是 dropdown。Table 视图是动态生成的,取决于来自服务器的输入数据。它适用于 UiTextFields。但我无法将其用于显示 UIPickerView。请指导我如何解决这个问题。提前致谢。

4

1 回答 1

0

编写委托方法UItextFiled

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
   [textField resignFirstResponder];
   [self setupPicker];        
}

并调用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];
}

当您单击UITextFiledUIPickerView显示在 AlertView 上时,上面的代码用于显示选择器视图。

于 2013-09-11T10:32:54.547 回答