To disable a control, you can set the Enabled property to No. This causes the control to ignore whatever touch events. After being disabled. Controls can also display themselves in different ways, for example, Gray is not available. Although it is completed by the subclass of the control. This attribute is present in the Uicontrol.
When the user selects the control, the Uicontrol class sets its selected property to Yes.
Subclasses sometimes use this property to let the control choose itself. Or to show different ways of behaving.
Contentverticalalignment
Controls how to lay out their own content in the vertical direction. By default, the content is top-to-bottom, and for text fields, it may be changed to Uicontrolcontentverticalalignmentcenter. For this field, the following values can be used:
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 registering and receiving events. This allows you to specify your control when a particular event occurs. Notifies a method of the proxy class. Suppose you want to register an event and be able to use the Addtarget side
Method:
[mycontrol addtarget:mydelegate Action: @selector (Myactionmethod:) forControlEvents: Uicontroleventvaluechanged];
Events can be combined with logical OR, so that multiple events can be specified again in a separate addtarget call.
The following events are supported by the base class Uicontrol unless otherwise noted. Also applies to all controls
Uicontroleventtouchdown
Single Touch Press event: The user touches the screen, or when a new finger falls.
uicontroleventtouchdownrepeat
Multi-touch Press event, touch count greater than 1: when the user presses the second to third or fourth finger.
uicontroleventtouchdraginside
When a touch is dragged inside the control pane.
uicontroleventtouchdragoutside
When a touch is dragged outside the control form.
Uicontroleventtouchdragenter
When a touch is dragged from outside the control form to inside.
Uicontroleventtouchdragexit
When a touch is dragged from inside the control form to the outside.
UIControlEventTouchUpInside
All touch lift events within the control.
uicontroleventtouchupoutside
All touch lift events outside the control (the touch must start with the inside of the control to send a notification).
Uicontroleventtouchcancel
All touch Cancel event. That is, one touch is canceled because it puts too many fingers. Either locked or interrupted by a phone call.
uicontroleventtouchchanged
When the value of the control has changed. Send notifications. Used for sliders, segmented controls, and other controls that take values.
You can configure when the slider control sends notifications when the slider is dropped. Or it is sent when it is dragged.
Uicontroleventeditingdidbegin
Send a notification when you start editing in a text control.
uicontroleventeditingchanged
A notification is sent when the text in the text control is changed.
Uicontroleventeditingdidend
Sends a notification when the edit ends in a text control.
uicontroleventeditingdidonexit
When the edit is finished by pressing ENTER (or equivalent behavior) within the text control. Send notifications.
uicontroleventalleditingevents
Notifies all events about text editing.
Uicontroleventallevents
Notifies all events.
To delete the corresponding action for one or more events, you can use the Removetarget method of the Uicontrol class. You can delete all actions for a given event target by using the nil value:
[MyControl removetarget:mydelegate Action:nil forcontrolevents:uicontroleventallevents];
To get a list of all specified actions for a control, you can use the Alltargets method. This method returns a Nsset that includes a complete list of events:
nsset* myactions = [Myconreol alltargets];
In addition, you can use the Actionsfortarget method to get a list of all the actions for a specific event target:
nsarray* myactions = [MyControl actionfortarget:uicontroleventvaluechanged];
Assume that you have designed a custom control class that can use the Sendactionsforcontrolevent method. Send notifications for major Uicontrol events or for your own defined events.
Like what. Assuming that your control's value is changing, you can
Send the corresponding notification. The control's code can specify a time target, and the notification will be propagated to those specified targets.
Cases:
[Self sendactionsforcontrolevents:uicontroleventvaluechanged];
When the entrusted class gets an event notification, he receives a pointer to the sender of the event. The following sample is used to handle the events of a segmented control. Your action method should follow a similar approach:
-(void) Myaction: (ID) sender{
uisegmentedcontrol* control = (uisegmentedcontrol*) sender;
if (Control = = myControl1) {
/ * Query control Get value * /
/* Respond to MYCONTROL1 action */
}
}
Uicontrol-ios Development