iOS Uicollectionview sliding operation

Source: Internet
Author: User

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

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.