如何避免iPhone中Bar Button项目的多次触摸?
我已经创建了工具栏并在该工具栏中设置了 UIBarbuttonItem。当我单击工具栏按钮时,我刚刚删除了一个自定义视图。我想避免多次触摸栏按钮项目,因为有时用户会多次单击栏按钮项目。(这种情况仅发生一段时间)。
这是我的示例代码,
UIBarButtonItem *closeBtn =[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(action)] autorelease];
toolBar.items = [NSArray arrayWithObjects:space,closeBtn,nil];
-(void) action
{
[customView removeFromSuperview];
}
所以我想在单击工具栏中的栏按钮时避免多次触摸。我如何检测栏按钮是否被选择?那么我该如何避免这个问题呢? 请帮帮我。
谢谢!
I have created tool bar and set the UIBarbuttonItem in that tool bar.When i clicks the bar button, i have just removed one custom view. I want to avoid the multiple touches of the bar button items, because sometimes the user clicks the bar button items more than one.( It happens some time only).
Here my sample code,
UIBarButtonItem *closeBtn =[[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(action)] autorelease];
toolBar.items = [NSArray arrayWithObjects:space,closeBtn,nil];
-(void) action
{
[customView removeFromSuperview];
}
So i want to avoid the multiple touch, when clicks the bar button in the tool bar. And how can i detect to the bar button is select?. So how can i avoid this problem?
Please help me out.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有多种可能的方法,但其中一种是将按钮设置为禁用。你需要稍微改变一下你的行动方法。
There are several possible approaches, but one is to set the button to disabled. You'll need to change your action method a bit.