It's Irritating ...!!!
I googled about this problem, found some Relative Questions
but not Satisfactory Answers
.
So I have One - (IBAction)
method that adds some UITextField's
Values to NSMutableArray
when "Add"
Button is Clicked. I am simply trying to show UIAlertView
, if the UITextField is empty.
My Code :
- (IBAction)addButtonPressed:(id)sender
{
if ([textField1.text length]==0 || [textField2.text length]==0 || !someFlag)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"MyApp" message:@"Please Enter Valid Data..." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
else
{
// Code to add textField's value to Array.
}
}
My Problem :
Whenever I press "Add" Button with empty textField , UIAlertView
appears thrice.
1) For the First Time It appears with "Close"
Button. (I have never added...) It disappears within some time.
2) Second Time It appears with "OK" Button. (That's what I added...) It disappears when I press "OK" Button.
3) Third Time It appears with "Close" Button again. It disappears when I press "Close" Button.
EDIT :
Similar Question : UIAlertView Pops Up Three Times per Call Instead of Just Once. Can someone help me to found solution from this ?