Customizing gestures based on Uitouch

Source: Internet
Author: User

The gestures and clicks provided by the system are often not enough to meet our needs, so we need to write our own desired clicks or sliding effects.

Let's introduce the app that I did when I was doing the reading of the ebook

As shown, we need to click on the middle of the pop-up menu (below the black bar) to the left green and yellow click to toggle the previous page, click on the right to switch to the next page, and all the locations on the screen support left to draw the next page, right to the previous page of the gesture

We redefine our gestures according to our needs.

The core idea is that we change the coordinates between where we clicked, and where the finger left the screen, first of all, if the coordinates of the start and end are not changed, then we can assume that it is a click event, and if the coordinates change, then it can be considered a sliding event.

1. First create UIView

2. Set two properties to record the start position, and end position of the click

3. Set the method to start touch view and End touch view at all times

We need to record the location of the click at this time StartPoint

The red arrow points to the place because our engineering uses arc, and in the case of MRC we can use [_target performselector:_action];

This line of code in the ARC state throws a warning, so we use the following code instead, we introduce a framework and define a macro when we replace it.

method to invoke at end

Here we add the left and right strokes and click on the triggered conditions, so that our custom gestures are over, and of course we can define the other gestures we need, according to this.

4. Call

At the time of the call, how do we set the trigger-time correlation method,

We're using proxies, but since we're trying to divide 5 areas, how do we make a distinction between what area we're clicking on, where I'm choosing the stupidest way to set up an agent for each of the different dry areas?

4.1 Setting up Proxies

Follow the agent

The other settings are the details of the settings, basically no big pits.

Customizing gestures based on Uitouch

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.