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:
- Creates a gesture instance. When creating gestures, specify a callback method that is called when the gesture starts, changes, or ends.
- 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