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];
|