0

我使用以下代码在 UIAlertView 中创建了一个 UIPickerView:

alert1 = [[UIAlertView alloc] initWithFrame:CGRectMake(0, 0, 300, 200)];
alert1.title = @"All Notes";
alert1.message = @"\n\n\n\n\n\n\n";
alert1.delegate = self;
[alert1 addButtonWithTitle:@"Cancel"];

 myPickerView = [[UIPickerView alloc] initWithFrame:CGRectZero];
 myPickerView.tag = TAG_PICKER0;
 myPickerView.delegate = self;
 myPickerView.showsSelectionIndicator = YES;
 myPickerView.autoresizingMask = UIAlertViewStyleDefault;
 myPickerView.frame = CGRectMake(10, 40, 265, 150);

 [alert1 addSubview:myPickerView];
 [alert1 show];

我想在按下按钮时重新加载这个pickerView,在按钮操作中我向出现在选择器中的数组添加了一个新元素,我还添加了这一行

[self.myPickerView reloadAllComponents];
self.myPickerView.delegate=self;

但是此时新元素没有出现在选择器中,它在我重新打开应用程序时出现

如何解决此问题以使新元素在添加时出现在 pickerView 中?

4

0 回答 0