Simple methods and gestures for creating arrays in iOS

Source: Internet
Author: User

Simple methods and gestures for creating arrays in iOS


In fact, outsourcing is also quite good. Although tired, the daily knowledge has been expanded a lot. The following are the gains of today.

① Method of initializing array-1 dictionary


@ [] Initializing an unchangeable Array

@ {} Initialize an unchangeable dictionary

② Use of gestures

In iOS, four methods are used before processing gestures:

-(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 this method is difficult for identifying different gesture operations.
  • UITapGestureRecognizer // click (you can set the number of clicks)

  • UIPinchGestureRecognizer // two refers to the internal or external movement, usually used for scaling

  • UIRotationGestureRecognizer // rotate

  • UISwipeGestureRecognizer // slide for Fast movement

  • UIPanGestureRecognizer // drag and drop, and move slowly

  • UILongPressGestureRecognizer // long press

  • Usage:

      Create a gesture instance. When creating a gesture, specify a callback method. When the gesture starts, changes, or ends, the callback method is called. Add to View to be recognized. Each gesture corresponds to only one View. When the screen is touched within the View boundary, if the gesture is the same as the predefined one, the method will be called back. Reference: http://blog.csdn.net/totogo2010/article/details/8615940
      Next let's talk about the problem I encountered. I added many imageviews to uiscrollview, and added gestures to imageview to execute gesture methods, but not touches, after checking a lot of information, the problem is solved. Specifically, because scrollview is added to self. the touches method can only receive self. the touch method on the view cannot monitor the scrollview method. scrollview has rewritten the four methods of touches (sliding gesture touch). To solve this problem, you need to rewrite the touches method in the scrollview.

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.