Click to open Uicollectionviewdelegate, found @protocol uicollectionviewdelegate <uiscrollviewdelegate>.
So as long as the implementation of Uiscrollviewdelegate
-(void) Scrollviewdidscroll: (uiscrollview *) ScrollView; method, you can override the Uicollectionview swipe operation
For example, with a imageview called testimg above the uicollection, you can use the following method to move along with the uicollection slide
1- (void) Scrollviewdidscroll: (Uiscrollview *) ScrollView2 {3Cgpoint point=Scrollview.contentoffset;4NSLog (@"%f,%f", POINT.X,POINT.Y);5 6CGRect frame =[_testimg frame];7FRAME.ORIGIN.Y = +-Point.y;8_testimg.frame =frame;9 Tenframe =[ScrollView frame]; OneFRAME.ORIGIN.Y =179-Point.y; AScrollview.frame =frame; -}
It is important to note that lines 43 and 11th of Line 7th of 179 are the initial y-axis values of testimg and Uicollectionview respectively, not the values before sliding. If you use
Control. ORIGIN.Y-= Point.y;
The Y value quickly becomes smaller, and the control flies out of the screen instantly
In the code above, point is the offset after sliding, the finger is slipping, the offset y is positive
iOS Uicollectionview sliding operation