- UIControl
- 作用:具有处理事件处理的控件父类
- 事件响应的3种形式:基于触摸,基于值,基于编辑
UIView ------ UIControl------UIButton
UIDatePicker
UIPageControl
UISegmentedControl
UITextField
UISlider
UISwitch
- 常用方法
- (void)addTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents//添加一个事件
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(UIControlEvents)controlEvents//移除一个事件
- 事件处理
//用户按下时触发
UIControlEventTouchDown
//点击次数大于1时触发
UIControlEventTouchDownRepeat
//当触摸在控件内拖动时触发
UIControlEventTouchDragInside
//当触摸在控件之外拖动时触发
UIControlEventTouchDragOutside
//当触摸从控件之外拖动到内部时触发
UIControlEventTouchDragEnter
//当触摸从控件内部拖动到外部时触发
UIControlEventTouchDragExit
//控件之内触摸抬起时
UIControlEventTouchUpInside
//控件之外触摸抬起时
UIControlEventTouchUpOutside
//触摸取消事件,设备被上锁或者电话呼叫打断
UIControlEventTouchCancel
//当控件的值发生改变时。用于滑块,分段控件等控件。
UIControlEventValueChanged // sliders, etc.
//文本控件开始编辑时
UIControlEventEditingDidBegin // UITextField
//文本控件的文本被改变
UIControlEventEditingChanged
//文本控件中编辑结束
UIControlEventEditingDidEnd
//文本控件内通过按下回车键结束编辑
UIControlEventEditingDidEndOnExit // 'return key' ending editing
//所有触摸事件
UIControlEventAllTouchEvents // for touch events
//文本编辑的所有事件
UIControlEventAllEditingEvents // for UITextField
//
UIControlEventApplicationReserved // range available for application use
//
UIControlEventSystemReserved // range reserved for internal framework use
//所有事件
UIControlEventAllEvents