這很刺激...... !!!uialertview不止一次致電
我GOOGLE了這個問題,發現了一些Relative Questions
但不Satisfactory Answers
。
所以我有一個- (IBAction)
方法,增加了一些UITextField's
值來NSMutableArray
時"Add"
按鈕被點擊。我只是試圖顯示UIAlertView
,如果UITextField是空。
我的代碼:
- (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.
}
}
我的問題:
每當我按「添加」 按鈕與空文本框,UIAlertView
出現三次。
1)首次出現與"Close"
按鈕。 (我從來沒有添加...)它在一段時間內消失。
2)第二次這似乎與「OK」 按鈕。 (這就是我添加的...)當我按下「OK」按鈕時,它消失。
3)第三次它與一起出現「關閉」再次按鈕。當我按「關閉」按鈕時它消失。
編輯:
類似的問題:UIAlertView Pops Up Three Times per Call Instead of Just Once。 有人可以幫我找到解決辦法嗎?
問題是與其他代碼不是這個代碼。檢查其他代碼。 –
你可以顯示與「關閉」按鈕 –
出現的alertView你有條件[textField.text isEqualToString:@「」] – KDeogharkar