如何禁用 UIButton? [英] How do I disable a UIButton?

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

问题描述

我正在做一个项目,我必须在一个 plist 中显示照片库的所有照片,并在 UIButtons 上水平显示它们.

I am working on a project in which I have to show all photos of Photo Library in a plist and show them horizontally on UIButtons.

我的应用程序也会有一个编辑按钮:当用户单击此按钮时,每个按钮上应该会显示一个删除标记(例如通常出现在其他 iPhone/iPad 应用程序中).

My app will also have an edit button: when the user clicks this button, a delete mark (such as usually appears in other iPhone/iPad apps) should show on each button.

但关键是:一旦这个删除标记出现,按钮的功能应该被禁用.我尝试使用以下方法完成此操作:

But here's the crucial bit: as soon as this delete mark appears, the functionality of the button should be disabled. I've tried accomplishing this with the following:

{
  editbutton.enabled=NO;
}

...但它既不会产生错误也不会起作用.我该怎么办?

...but it neither produces an error nor works. What should I do?

推荐答案

请设置这个...

 editButton.userInteractionEnabled = NO; 

或者你可以使用

 editButton.enabled = NO;

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

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