我有一个UIPicker,当选中一行时触发UIAlert。我试图在UIPicker“完成”按钮被按下并且UIPicker关闭后弹出警报。此时警报会在选中该行时触发。所以,当某人在选择器中滚动每一行时,UIAlert会一直弹出。UIPlerter关闭UIPicker后弹出
感谢您的帮助
这里的“完成”按钮代码:
-(IBAction)done{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
CGAffineTransform transform = CGAffineTransformMakeTranslation(0, 480);
pickerView.transform = transform;
[UIView commitAnimations];
}
这里的选择器UIAlert代码样本显示“的情况下0”与所述提示消息一起:
- (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;
}
为什么您在选择该行时触发警报?按下时完成。 – Akshay
我不认为UIPickerView默认内置了一个“完成”按钮(或任何按钮)。 – chown
我会怎么做呢?我有一系列开关(行){0}:}情况下触发警报。有没有办法保持这些,只有按'完成'时才触发警报? – hanumanDev