也许有更好的方法,但我想在用户点击 UIalertView 中的按钮时弹出一个选择列表。我希望在警报视图仍然可见时弹出此列表,并在用户点击选择列表中的项目时关闭所有内容。
我想我可以通过将列表添加为 UIAlertView 中的子视图并保持 UIalertView 在 while 循环中显示 NSRunLoop 并弹出选择列表设置的标志。但是,我无法让它工作,因为在 while 循环回到 NSRunLoop 之前没有设置标志。第二次点击会让它退出 while 循环,但这不是我想要的。
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex{
CGRect popUpPickerFrame = alertView.frame;
PopUpPicker *popUpPicker = [[PopUpPicker alloc] initWithFrame:CGRectMake(popUpPickerFrame.origin.x +150,popUpPickerFrame.origin.y-50,115,250)];
popUpPicker.delegate = self;
popUpPicker.aList = [NSArray arrayWithObjects:@"General Plan", @"Light Plan", @"Melatonin Plan", @"Bed Times", @"Done", nil];
popUpPicker.tag = 10;
[alertView addSubview:popUpPicker];
while (popUpPicker.tag == 10) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate distantFuture]];
}
[popUpPicker release];
}
我将 popUpPicker.tag 设置为用户在 tableView:didSelectRowAtIndexPath: 列表的方法中点击的行,然后调用列表委托方法。
我可以让弹出列表正常工作,但只有在 UIAlertView 关闭之后。
谢谢你的帮助。
约翰