使用第三方 :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];
創(chuàng)建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;
// 添加下拉刷新頭部控件
[self.Colletion addHeaderWithCallback:^{
// 進(jìn)入刷新狀態(tài)就會回調(diào)這個Block
// 增加5條假數(shù)據(jù)
// for (int i = 0; i<5; i++) {
// [vc.fakeColors insertObject:MJRandomColor atIndex:0];
// }
// 模擬延遲加載數(shù)據(jù),因此2秒后才調(diào)用)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[vc.Colletion reloadData];
// 結(jié)束刷新
[vc.Colletion headerEndRefreshing];
});
}];
}
#pragma mark - collection數(shù)據(jù)源代理
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 5;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView
dequeueReusableCellWithReuseIdentifier:MJCollectionViewCellIdentifier
forIndexPath:indexPath];
cell.backgroundColor = [UIColor redColor];
return cell;
}
附件:http://down.51cto.com/data/2364897另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
網(wǎng)站題目:CollectionView下拉刷新(第三方)-創(chuàng)新互聯(lián)
標(biāo)題鏈接:http://chinadenli.net/article6/gdcig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、品牌網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計公司、企業(yè)建站、品牌網(wǎng)站建設(shè)、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容