Easy ways to create arrays in iOS and gesture usage

Source: Internet
Author: User


In fact, outsourcing is also very good, although tired point, but the knowledge of the expansion of many, the following is today's harvest

① initializing a Dictionary of arrays


@[] Initializing immutable groups

@{} Initialize immutable dictionary

Use of ② gestures

There are four ways to handle gestures in iOS:

-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event
  -(void) touchescancelled: (NSSet *) Touches withevent: (uievent *) event
  -( void) touchesended: (Nsset *) touches withevent: (uievent *) event
  -(void) touchesmoved: (Nsset *) touches withevent: (Uievent *) event

these four methods are written in the underlying uiresponder, but it's really a hassle to identify different gestures in this way The Apple gives a simpler way--gestures
  • uitapgesturerecognizer //Click (You can set the number of clicks)

  • uipinchgesturerecognizer // Two means to move inward or outward, usually using the zoom

  • uirotationgesturerecognizer // rotate

  • uiswipegesturerecognizer // Swipe to move quickly

  • uipangesturerecognizer // Drag, slow move

  • uilongpressgesturerecognizer // Long press

  • Use:

    1. Creates a gesture instance. When creating gestures, specify a callback method that is called when the gesture starts, changes, or ends.
    2. Added to the view that needs to be recognized. Each gesture corresponds to only one view, and when the screen touches within the bounds of the view, if the gesture is the same as the reservation, the callback method is used.
Reference: http://blog.csdn.net/totogo2010/article/details/8615940
The following is the question I encountered, I added a lot of imageview on the Uiscrollview, the ImageView to add a gesture, can execute gesture method, but will not perform touches four methods, check a lot of data results resolved , specifically:because ScrollView is added to the Self.view, touches method can only receive self.view on the touch method, can not monitor the ScrollView method,ScrollView has been to touches four method overrides (swipe gesture touch) to solve this problem requires yourself to rewrite the touches method in ScrollView

Easy ways to create arrays in iOS and gesture usage

Related Article

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.