collectionView

pscollection:
_collectionView = [[PSCollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, WinSize.height-64-49)];
    self.collectionView.backgroundColor = BGCOLOR;//[UIColor colorWithPatternImage:[UIImage imageNamed:@"seller_bg"]];
    self.collectionView.collectionViewDelegate = self;
    self.collectionView.collectionViewDataSource = self;
    self.collectionView.delegate = self;
    self.collectionView.numColsPortrait = 2; // 显示几列
    self.collectionView.numColsLandscape = 2;
    [self loadFooterView];
    [self.view addSubview:self.collectionView];
    [self.collectionView reloadData];

pullPsCollection:

self.collectionView = [[PullPsCollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, self.view.bounds.size.height)];
    NSLog(@"winsize.height = %f",Winsize.height);
    self.collectionView.collectionViewDelegate = self;
    self.collectionView.collectionViewDataSource = self;
    self.collectionView.pullDelegate=self;
    self.collectionView.delegate = self;
    
    
    
    self.collectionView.backgroundColor = [UIColor whiteColor]; //网格背景色
    self.collectionView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    
    self.collectionView.numColsPortrait = 2; // 显示几列
    self.collectionView.numColsLandscape = 2; //未知
    //箭头
    self.collectionView.pullArrowImage = [UIImage imageNamed:@"arrow"];
    //下拉区域背景色
    self.collectionView.pullBackgroundColor = [UIColor whiteColor];
    //下拉显示文字
    self.collectionView.pullTextColor = [UIColor brownColor];
    
    //loadingView
    UILabel *vv = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    vv.center = CGPointMake(self.view.center.x, self.view.center.y-80);
    vv.layer.masksToBounds = YES;
    vv.text = @"Loading...";
    vv.textAlignment = UITextAlignmentCenter;
    vv.textColor = [UIColor whiteColor];
    vv.layer.cornerRadius = 5.f;
    vv.backgroundColor = [UIColor blackColor];
    vv.alpha = 0.6;
    <pre name="code" class="objc">    self.collectionView.loadingView = vv;


if(!self.collectionView.pullTableIsRefreshing) { self.collectionView.pullTableIsRefreshing = YES; [self performSelector:@selector(refreshTable) withObject:nil afterDelay:1]; } [self.view addSubview:self.collectionView]; [self loadScrollerView];

 

#pragma -mark PSCollectionViewDelegate  &&  PSCollectionViewDataSource
- (void) refreshTable
{
    [self.imageArray removeAllObjects];
    [self loadDataTest];
    self.collectionView.pullLastRefreshDate = [NSDate date];
    self.collectionView.pullTableIsRefreshing = NO;
    [self.collectionView reloadData];
}

- (void) loadMoreDataToTable
{
    [self.imageArray addObjectsFromArray:self.imageArray];
    [self.collectionView reloadData];
    self.collectionView.pullTableIsLoadingMore = NO;
}

#pragma mark - PullTableViewDelegate

- (void)pullPsCollectionViewDidTriggerRefresh:(PullPsCollectionView *)pullTableView
{
    [self performSelector:@selector(refreshTable) withObject:nil afterDelay:1.0f];
}

- (void)pullPsCollectionViewDidTriggerLoadMore:(PullPsCollectionView *)pullTableView
{
    [self performSelector:@selector(loadMoreDataToTable) withObject:nil afterDelay:1.0f];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
- (PSCollectionViewCell *)collectionView:(PSCollectionView *)collectionView viewAtIndex:(NSInteger)index {
    CellView *cell = (CellView *)[self.collectionView dequeueReusableView];
    if (cell == nil) {
        cell = [[CellView alloc] init];
        cell.backgroundColor = [UIColor lightGrayColor];//[self.colors objectAtIndex:n];
        cell.layer.masksToBounds = YES;
        cell.layer.cornerRadius = 5.f;
    }
    return cell;
}

- (CGFloat)heightForViewAtIndex:(NSInteger)index {
    NSLog(@"self.collectionView.colWidth = %f",self.collectionView.colWidth);
//    [PSCollectionViewCell heightForViewWithObject:item inColumnWidth:self.collectionView.colWidth]
    int n = arc4random()%100 + 150;
    
    return n;
}

- (void)collectionView:(PSCollectionView *)collectionView didSelectView:(PSCollectionViewCell *)view atIndex:(NSInteger)index {
    // Do something with the tap
    NSLog(@"index = %i",index);
    HomeDetailViewController *controller = [[HomeDetailViewController alloc] initWithNibName:nil bundle:nil];
//    [ABTabBarViewController hideTabBarLevel:YES];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:controller animated:YES];
    self.hidesBottomBarWhenPushed = NO;
}

- (NSInteger)numberOfViewsInCollectionView:(PSCollectionView *)collectionView {
    return self.imageArray.count;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值