Difference between enabled and userInteractionEnabled properties

原创 2015年07月08日 10:46:14



I read through the documentation, and here are my findings.

UIButton inherits from UIControl the boolean property enabled

A Boolean value that determines whether the receiver is enabled.

Specify YES to make the control enabled; otherwise, specify NO to make it disabled. The default value is YES. If the enabled state is NO, the control ignores touch events and subclasses may draw differently.

UIControl inherits from UIView the boolean property userInteractionEnabled:

A Boolean value that determines whether user events are ignored and removed from the event queue.

When set to NO, user events—such as touch and keyboard—intended for the view are ignored and removed from the event queue. When set to YES, events are delivered to the view normally. The default value is YES.

From this I conclude

  • button.userInteractionEnabled = NO means the button looks normal but doesn't respond to touches (from the UIView inheritance).

  • button.enabled = NO means the button is grayed out and doesn't respond to touches (from the UIControl inheritance). 


总的来说, userInteractionEnabled = NO,view看起来还是正常的,但是不能响应点击事件。

enabled = NO, view会变灰,如果有文字,文字也会变灰色。view也不能响应点击事件。


相关文章推荐

Difference_between_PLMN_and_PSTN

  • 2008年11月06日 10:48
  • 41KB
  • 下载

the difference between “adduser” and “useradd”

在Ubuntu中创建新用户,通常会用到两个命令:useradd和adduser。虽然作用一样,但用法却不尽相同: 1. 使用useradd时,如果后面不添加任何参数选项,例如:#sudo use...

Difference between FX2 and FX2LP

  • 2013年11月06日 14:02
  • 512KB
  • 下载

C++ String: What is the difference between '\n' and '\r\n'?

C++ String: What is the difference between '\n' and '\r\n'? Q: What is the difference between...
  • yinzch
  • yinzch
  • 2011年12月08日 12:53
  • 153

Difference Between XML and XAML

XML  vs XAML XML, or Extensible Markup Language, is a subset  of the more complex SGML (Standard Ge...
  • NewWeed
  • NewWeed
  • 2012年09月24日 20:29
  • 203

What is the difference between a definition and a declaration?

原帖: http://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-dec...

What's the difference between CUDA shared and global memory?

What's the difference between CUDA shared and global memory? 1.When we use cudaMalloc() In order to...
  • ywcpig
  • ywcpig
  • 2015年05月28日 20:08
  • 337

The difference between 'typedef' and '#define'

一、typedef的用法 在C/C++语言中,typedef常用来定义一个标识符及关键字的别名,它是语言编译过程的一部分,但它并不实际分配内存空间,实例像: typedef    int     ...
  • hjx5200
  • hjx5200
  • 2012年09月27日 22:18
  • 253

Difference between cu.* and tty.*

For those that are interested.   Serial ports are commonly misunderstood.  Having been involved wi...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Difference between enabled and userInteractionEnabled properties
举报原因:
原因补充:

(最多只允许输入30个字)