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)