uialertview 多次调用 [英] uialertview called more than once

查看:22
本文介绍了uialertview 多次调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很烦人......!!!

It's Irritating ...!!!

我搜索了这个问题,发现了一些 Relative Questions,但没有找到 Satisfactory Answers.

I googled about this problem, found some Relative Questions but not Satisfactory Answers.

所以我有一个 - (IBAction) 方法,当 "Add" 时将一些 UITextField's 值添加到 NSMutableArray 按钮被点击.如果 UITextField 为 empty,我只是想显示 UIAlertView.

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.

我的代码:

- (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.
        }
}

我的问题:

每当我按下带有 empty textField"Add" 按钮时,UIAlertView 就会出现 三次.

Whenever I press "Add" Button with empty textField , UIAlertView appears thrice.

1) 首次出现带有关闭" 按钮.(我从未添加过...)它会在一段时间内消失.

1) For the First Time It appears with "Close" Button. (I have never added...) It disappears within some time.

2) 第二次出现 确定" 按钮.(这就是我添加的...)当我按下 确定" 按钮时它会消失.

2) Second Time It appears with "OK" Button. (That's what I added...) It disappears when I press "OK" Button.

3) 第三次 再次出现关闭"按钮.当我按下 关闭" 按钮时它会消失.

3) Third Time It appears with "Close" Button again. It disappears when I press "Close" Button.

类似问题:UIAlertView 弹出三个每次通话的次数而不是一次.有人可以帮我找到解决方案吗?

Similar Question : UIAlertView Pops Up Three Times per Call Instead of Just Once. Can someone help me to found solution from this ?

推荐答案

奇怪....!!!

有时,当您过度烦躁时,您会完全忽略某些代码行.它也发生在我身上.我忽略了从 -addButtonPressed Method 调用的一种方法,其中有一个 AlertView (当然带有 "Close" 按钮).

Sometimes it happens that you Totally Neglect certain lines of your code When you are Over-Irritated. It happend to me also. I neglected one method that is called from -addButtonPressed Method , Which has One AlertView (With "Close" Button of course) inside it.

这就是解决方案本身!!!

That's the Solution itself !!!

这篇关于uialertview 多次调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆