UIImageView之userInteractionEnabled 属性
来源:互联网 发布:天猫红包怎么领取淘宝 编辑:程序博客网 时间:2024/05/16 06:53
我们往往喜欢用UIImageView最为我们程序的背景,然后再在其上面添加其他的控件。如果直接拖到控件到UImageView上面,可以发现控件并不是属于UIImageView,而是与其并列属于UIView的。但是用代码加的话发现可以用addSubView:方法给它上面加控件,但是程序运行起来就会发现UIImageView上面的控件(比如UIButton、UITextField)根本无法响应事件。这就要用到它的userInteractionEnabled 属性。
苹果帮助文档是这样解释的:
New image view objects are configured to disregard user events by default.
If you want to handle events in a custom subclass of UIImageView, you must explicitly change the value of the userInteractionEnabled property to YES after initializing the object.
userInteractionEnabled
A Boolean value that determines whether user events are ignored and removed from the event queue.
@property(nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled
Discussion
This property is inherited from the UIView parent class. This class changes the default value of this property to NO.
Availability
- Available in iOS 2.0 and later.
Declared In
UIImageView.h
这就说明UIImageView默认是忽略事件的,不会响应事件的(用代码添加,会发现这个效果)。只有修改它的这个属性为YES它上面的控件才可以响应事件。也可以将其他控件直接加到VIew上面与UIImageView并列。
0 0
- UIImageView之userInteractionEnabled 属性
- UIImageView userInteractionEnabled
- UIView 之userInteractionEnabled 属性
- UIView之userInteractionEnabled属性介绍
- UIView之userInteractionEnabled属性介绍
- UIView之userInteractionEnabled属性介绍
- UIView之userInteractionEnabled属性介绍
- UIImageView 之 contentMode属性
- [iOS diary] UIImageView,UILabel等加gesture recognizer不成功,神秘属性userInteractionEnabled
- UIView userInteractionEnabled属性
- userInteractionEnabled属性理解
- UIView的userInteractionEnabled属性
- UIImageView默认的UserInteractionEnabled是NO
- UIImageView默认的UserInteractionEnabled是NO
- 关于UIView的userInteractionEnabled属性
- 关于UIView的userInteractionEnabled属性
- 关于UIView的userInteractionEnabled属性
- 关于UIView的userInteractionEnabled属性
- iOS设计模式---委托
- 解析器模式
- iOS设计模式---单例模式
- ios之快速枚举
- 把UITextField等控件加到UITollBar上面
- UIImageView之userInteractionEnabled 属性
- Objective-C之@encode关键字
- Objective-C语法之动态类型常用方法总结
- 用代码分割一张图片的方法
- IOS面试攻略(1.0)
- ios面试攻略(1.1)
- Oracle自增ID实现
- ios面试攻略(2.0)
- ios面试攻略(2.1)