Lan Yi iOS Learning Uicollectionview Live Carousel Map

Source: Internet
Author: User

Today, Liu Guobin teacher spoke about the access and use of JSON data sources, through the real-life project of micro-blogging practice, the data obtained are the actual data requested on the network, this method is easy to learn, easy to understand. Liu Guobin teacher To do today's exercises Uicollectionview the method of realizing the function of the carousel is down, we learn very convenient.
To implement the Carousel chart effect:

1. Create layout (uicollectionviewflowlayout)

2. Set layout orientation default up and down

3. Create Uicollectionview

4. Set delegate DataSource and comply with the Agreement (3 protocols)

5. Two ways to implement the DataSource protocol

6. Create a custom cell class create a control in the initialization method of the cell

7. Register the Cell

8. Protocol method for adding the number of control groups the third one in Datasourcedelegate

9. Add a method to control the cell size

10. Add line spacing of 0

11. Let the CollectionView up and roll to the No. 0 of group No. 2500.

12. Add a timer to execute a Jumppage method every 2 seconds

13. Get the location of the currently displayed cell in the Jumppage method

14. Let Item+1 get a new position based on the current position and let CollectionView scroll to a new location

15. Protocol method for implementing scrollviewdelegate the timer stops when you start dragging

16. The timer starts again at the end of the drag
-(void) Viewdidload {

[Super Viewdidload];

Uicollectionviewflowlayout *layout=[[uicollectionviewflowlayout Alloc]init];

Layout.scrolldirection=uicollectionviewscrolldirectionhorizontal;

Uicollectionview *cv=[[uicollectionview Alloc]initwithframe:cgrectmake (+, +, +) Collectionviewlayout:layout ];

cv.datasource=self;

cv.delegate=self;

Cv.pagingenabled=yes;

[Self.view ADDSUBVIEW:CV];

Registered

[CV Registerclass:[mycollectionviewcell class] forcellwithreuseidentifier:@ "cell"];

Position to move directly when the CollectionView starts

[CV scrolltoitematindexpath:[nsindexpath indexpathforitem:0 insection:500] Atscrollposition: Uicollectionviewscrollpositionleft Animated:yes];

Lan Yi iOS Learning Uicollectionview Live Carousel Map

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.