uialertview called more than once(uialertview 多次调用)
问题描述
这很烦人......!!!
It's Irritating ...!!!
我搜索了这个问题,发现了一些 Relative Questions
,但没有找到 Satisfactory Answers
.
I googled about this problem, found some Relative Questions
but not Satisfactory Answers
.
所以我有一个 - (IBAction)
方法,当 "Add" 时将一些
按钮被点击.如果 UITextField 为 empty,我只是想显示 UITextField's
值添加到 NSMutableArray
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 多次调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:uialertview 多次调用


- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- UITextView 内容插图 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- GPS状态的广播接收器? 2022-01-01
- URL编码Swift iOS 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01