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.