Home » IOS » The properties and usage of UIday0604:UIControl

The properties and usage of UIday0604:UIControl

UIControl is all controls (such as UIButton, UISlider, UISegmentedControl) of the base class.


as long as the controls associated with the control are inherited from that class,.


The kernel of

UIControl function:


.

addTarget: action: to add the event by forControlEvents: control method

removes the event forControlEvents: through the removeTarget: action:.


properties



Enabled

The control is enabled by default. To disable controls, you can set the enabled property to NO, which will cause the control to ignore any touch events. The control is disabled, can also display themselves in different ways, such as grey is not available. Although it is completed by the control class, but exist in UIControl.
attribute




Selected

When a user selects a control, the UIControl class sets its selected attribute to the YES. subclass, and sometimes uses this property to let the control select itself, or to behave differently,.





ContentVerticalAlignment

How to control the content of its layout in the vertical direction. The default is on the top of the content, the text field that may be changed into UIControlContentVerticalAlignmentCenter. in this field, you can use the following values:



1.

UIControlContentVerticalAlignmentCenter



2.

UIControlContentVerticalAlignmentTop



3.

UIControlContentVerticalAlignmentBottom



4.

UIControlContentVerticalAlignmentFill



ContentHorizontalAlignment

Horizontal direction



1.

UIControlContentHorizontalAlignmentCenter



2.

UIControlContentHorizontalAlignmentTop



3.

UIControlContentHorizontalAlignmentBottom



4.

UIControlContentHorizontalAlignmentFill





event notification





The UIControl class provides a standard mechanism for event registration and reception. This makes you can control your specified on specific events, a method of notifying the proxy class. If you want to register an event, you can use the addTarget



Methods:

[myControl, addTarget:, myDelegate, action:@selector (myActionmethod:) forControlEvents:UIControlEventValueChanged];



Events can be merged together with logical OR, so you can specify multiple events in a separate addTarget call again. The following events are supported by the base class UIControl, and apply to all control
, unless otherwise noted




UIControlEventTouchDown



Single touch press event: when the user touches the screen, or another novice drops off,.





UIControlEventTouchDownRepeat



Multi touch press event, touch count is greater than 1: user press two, three, or fourth fingers,.





UIControlEventTouchDragInside



When a touch is dragged inside the control window,.





UIControlEventTouchDragOutside



When a touch drags outside the control window,.





UIControlEventTouchDragEnter



When a touch is dragged from the control window to the inside,.





UIControlEventTouchDragExit



When a touch is dragged from the control window to the outside,.





UIControlEventTouchUpInside



All events within the control that touch up.





UIControlEventTouchUpOutside



All events outside the control touch up event (point touch must start and notify within the control).





UIControlEventTouchCancel



All touch cancel events, that is, a touch is cancelled because of too many fingers, or locked or interrupted by a telephone call,.





UIControlEventTouchChanged



When the control value is changed, send notifications for the slider control and other control section, the value. You can configure the slider control when sending the notice, send in the slide is down, or send in drag.





UIControlEventEditingDidBegin



Sends notification.
when the text control starts editing




UIControlEventEditingChanged



Sends a notification.
when the text in the text control is changed




UIControlEventEditingDidEnd



Send a notification when the edit is finished at the text control.





UIControlEventEditingDidOnExit



When a text control is finished by pressing the return key (or equivalent behavior), the notification.
is sent




UIControlEventAllEditingEvents



Tell all events about text editing.





UIControlEventAllEvents



Notify all events.





To delete the action of one or more events, you can use the removeTarget method of the UIControl class. Using the nil value, you can delete all actions of a given event object:



[myControl, removeTarget:myDelegate, action:nil, forControlEvents:UIControlEventAllEvents],





To get a list of all the specified actions for a control, you can use the allTargets method. This method returns a NSSet containing the full list of events:



NSSet* myActions = [myConreol, allTargets];





In addition, you can also use the actionsForTarget method to obtain the full list of actions for a specific event target:



NSArray* myActions = [myControl, actionForTarget:UIControlEventValueChanged];





If the design of a custom control class, you can use the sendActionsForControlEvent method to send a notification, custom event UIControl basic events or their own. For example, if your control values are changing, you can



Send the corresponding notification, through the code of the control, you can specify the time target, this notification will be spread to these designated targets. Example:



[self, sendActionsForControlEvents:UIControlEventValueChanged];





When the class get notification, he will receive a pointer to the event sender pointer. The following example for piecewise control event, your action method (action method) should follow similar treatment modalities:

- - (void) myAction: (ID) sender{



UISegmentedControl* control = (UISegmentedControl*) sender;

If (control = = myControl1) {



Query control value of
/ * * /


In response to the action of myControl1 / * * /


}
}



copyright notice: This article is original article for blogger. Without permission from blogger,.

must not be reprinted

Latest