iOS development gesture Gesture (ii)

Source: Internet
Author: User

Interacting with other user interface controls

Uicontrol subclasses will overwrite Parentview's gesture. For example, when a user clicks on UIButton, UIButton accepts a touch event, and its parentview is not received. This applies only to the control of the default action for gesture recognition overlap, including:

    • One finger click action: UIButton, Uiswitch, Uistepper, Uisegmentedcontrol, and Uipagecontrol.
    • One finger rub touch action: UISlider
    • One finger drag action: Uiswitch

  Events with multi-touch

In iOS, touch refers to a finger sliding and moving on the screen. A gesture is one or more fingers, and its class is a Uitouch object. Multi-touch events are uieventtypetouches

When touch occurs, the following methods are triggered:

    • Touchesbegan:withevent: Occurs when touching the screen
    • Touchesmoved:withevent: Occurs when the finger moves on the screen
    • Touchesended:withevent: Occurs when touch ends, that is, when the finger leaves the screen
    • Touchescancelled:withevent: Occurs when Touch is canceled by the system, and the touch is canceled if a phone is available

Change the default event delivery order

You can change the default event pass by changing the properties of the Uigesturerecognizer subclass.

    • @property (nonatomic) BOOL Delaystouchesbegan;  Default is NO. Causes all-touch events to is delivered to the target view only after this gesture have failed recognition. Set-to-YES-prevent views from processing any touches, that is, recognized as part of this gesture
    • @property (nonatomic) BOOL delaystouchesended; Default is YES. Causes touchesended events to is delivered to the target view only after this gesture have failed recognition. This ensures, a touch that's part of the gesture can being cancelled if the gesture is recognized

If a gesture recognizer detects a touch that does not belong to it, it sends the gesture directly to its view, and the ignoretouch:forevent is called: The method is passed directly to the view.

To create a custom gesture recognizer step

    • To create a subclass of Uigesturerecognizer
    • #import <UIKit/UIGestureRecognizerSubclass.h>
    • The following methods are overloaded in sub-classes
  1.-(void) reset;2.-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event;3.-(void) Touchesmoved: (Nsset *) touches withevent: (Uievent *) event;4.-(void) touchesended: (Nsset *) touches withevent: (UIEvent * ) event;5.-(void) touchescancelled: (Nsset *) touches withevent: (Uievent *) event;  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.