uialertview不止一次打电话 [英] uialertview called more than once

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

问题描述

这是刺激...... !!!

It's Irritating ...!!!

我搜索了这个问题,找到了一些 相关问题 但不是 令人满意的答案

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

所以我有一个 - (IBAction)将一些 UITextField的值添加到 NSMutableArray 当 添加 单击按钮时。我只是想显示 UIAlertView ,如果UITextField 为空

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

我的问题:

每当我按添加按钮空textField UIAlertView 显示三次

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

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

2)第二次出现OK 按钮。 (这就是我添加的内容......)当我按确定按钮时,它会消失。

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 方法调用的方法,它有一个 AlertView (带里面有关闭按钮)。

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天全站免登陆