我有一个 UIPicker 在选择一行时触发 UIAlert 。我试图在按下 UIPicker“完成”按钮并关闭 UIPicker 后弹出警报。At the moment the alert triggers when the row is selected. 因此,当有人滚动选择器中的每一行时,UIAlert 会不断弹出。
谢谢你的帮助
这是“完成”按钮代码:
-(IBAction)done{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 480);
pickerView.transform = transform;
[UIView commitAnimations];
}
这是显示“案例 0”以及警报消息的选择器 UIAlert 代码示例:
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
UIColor *newColor;
switch (row) {
case 0:
newColor = [UIColor yellowColor];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert" message:@"message" delegate:nil cancelButtonTitle:@"cancel" otherButtonTitles:nil];
[alert show];
[alert release];
myLabel.text = @"sometext";
break;
}