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;
}