重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

CollectionView下拉刷新(第三方)-创新互联

使用第三方 :MJRefresh

创新互联技术团队10年来致力于为客户提供网站设计制作、成都做网站、品牌网站制作全网营销推广、搜索引擎SEO优化等服务。经过多年发展,公司拥有经验丰富的技术团队,先后服务、推广了数千家网站,包括各类中小企业、企事单位、高校等机构单位。
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];



创建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:^{
        // 进入刷新状态就会回调这个Block
        
        // 增加5条假数据
        //        for (int i = 0; i<5; i++) {
        //            [vc.fakeColors insertObject:MJRandomColor atIndex:0];
        //        }
        
        // 模拟延迟加载数据,因此2秒后才调用)
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [vc.Colletion reloadData];
            // 结束刷新
            [vc.Colletion headerEndRefreshing];
        });
    }];
    
}

#pragma mark - collection数据源代理
- (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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页名称:CollectionView下拉刷新(第三方)-创新互联
本文地址:http://cqcxhl.com/article/gdcig.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP