Collectionview pull-down refresh (third-party)

Source: Internet
Author: User

Third-party: mjrefresh

Nsstring * const mjcollectionviewcellidentifier = @ "cell";-(bool) Application :( uiapplication *) Application didfinishlaunchingwithoptions :( nsdictionary *) launchoptions {self. window = [[uiwindow alloc] initwithframe: [[uiscreen mainscreen] bounds]; // override point for customization after application launch. self. window. backgroundcolor = [uicolor whitecolor]; Create collectionview uicollectionviewflowlayout * layout = [[uicollectionviewflowlayout alloc] init]; layout. itemsize = cgsizemake (80, 80); layout. sectioninset = uiedgeinsetsmake (20, 20, 20, 20); layout. minimuminteritemspacing = 20; layout. minimumlinespacing = 20; self. colletion = [[colletionview alloc] initwithframe: [[uiscreen mainscreen] bounds] collectionviewlayout: Layout]; self. colletion. alwaysbouncevertical = yes; self. colletion. backgroundcolor = [uicolor purplecolor]; self. colletion. datasource = self; [self. colletion registerclass: [uicollectionviewcell class] forcellwithreuseidentifier: mjcollectionviewcellidentifier]; [self addheader]; [self. window addsubview: Self. colletion]; [self. colletion release]; [self. window makekeyandvisible]; return yes;}-(void) addheader {_ unsafe_unretained typeof (Self) VC = self; // Add a drop-down refresh header control [self. colletion addheaderwithcallback: ^ {// when the refreshing status is enabled, the block will be called back. // five false data entries are added. // For (INT I = 0; I <5; I ++) {// [VC. fakecolors insertobject: mjrandomcolor atindex: 0]; // simulate the delay in loading data, so it is called 2 seconds later.) dispatch_after (dispatch_time (dispatch_time_now, (int64_t) (2.0 * nsec_per_sec), dispatch_get_main_queue (), ^ {[VC. colletion reloaddata]; // end the refresh [VC. colletion headerendrefreshing] ;}}] ;}# Pragma mark-collection data source proxy-(nsinteger) collectionview :( uicollectionview *) collectionview numberofitemsinsection :( nsinteger) Section {return 5 ;} -(uicollectionviewcell *) collectionview :( uicollectionview *) collectionview cellforitematindexpath :( nsindexpath *) indexpath {uicollectionviewcell * cell = [collectionview layout: FIG path: indexpath]; cell. backgroundcolor = [uicolor redcolor]; return cell ;}

Collectionview pull-down refresh (third-party)

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.