也许有更好的方法,但我想在用户点击UIalertView中的按钮时弹出一个选择列表。我希望在警报视图仍然可见时弹出此列表,并在用户点击选项列表中的项目时关闭所有内容。
我想我可以通过将列表添加为UIAlertView中的子视图来实现这一点,并在while循环中使用NSRunLoop显示UIalertView,该循环弹出一个由选择列表设置的标志。但是,我不能让它工作,因为在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:方法中点击的行,然后调用lists委托方法。
只有在UIAlertView关闭之后,我才能让弹出列表正常工作。
谢谢你的帮助。
约翰
发布于 2011-12-24 07:16:08
您的工作流程不适用于UIAlertView的概念。它不是为了在您按下某个按钮后在列表中提供选项而设计的。有人在WWDC 2011上说:“不要与框架抗争。”这个建议是给你的。除非确实需要,否则请避免发出警报,考虑对您的任务使用操作表,或在ViewController中实现工作流。
https://stackoverflow.com/questions/5089049
复制相似问题