UICollectionView 简单实现
来源:互联网 发布:网络兼职广告语大全集 编辑:程序博客网 时间:2024/05/24 05:28
- (void)viewDidLoad{ [super viewDidLoad]; //// 1. 添加头部控件的方法// [_collection addHeaderWithTarget:self action:@selector(headerRereshing)];//// 或者//// [self.tableView addHeaderWithCallback:^{ }];// //// 2. 添加尾部控件的方法// [_collection addFooterWithTarget:self action:@selector(footerRereshing)]; // [self.tableView addFooterWithCallback:^{ }]; self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ham.png"] style:UIBarButtonItemStylePlain target:self action:@selector(buttonAction:)]; self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"Refresh.png"] style:UIBarButtonItemStylePlain target:self action:@selector(RefreshAction:)]; // Do any additional setup after loading the view. self.navigationItem.title= @"首页"; self.navigationController.navigationBar.translucent=NO; UICollectionViewFlowLayout * layout=[[UICollectionViewFlowLayout alloc]init]; layout.itemSize = CGSizeMake(130, 120);//方块大小 layout.minimumLineSpacing = 10;//纵间距 layout.minimumInteritemSpacing = 10 ;//行间距 layout.scrollDirection =UICollectionViewScrollDirectionVertical;//纵向 layout.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20);//方块与边框上左下右间距 //创建collectionview _collection=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height-64-49) collectionViewLayout:layout]; [layout release]; [_collection setBackgroundColor:[WebColor antiqueWhite]]; _collection.delegate=self; _collection.dataSource=self; [_collection registerClass:[HomepageViewUICollectionViewCell class] forCellWithReuseIdentifier:@"collection"]; [self.view addSubview:_collection];}#pragma mark-#pragma mark- collectionview必须实现的俩个协议- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return [self.collectionArray count];}- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ HomepageViewUICollectionViewCell * cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"collection" forIndexPath:indexPath]; HomePageModel * model=[self.collectionArray objectAtIndex:indexPath.row]; cell.title.text= model.title; cell.number.text=model.number; [cell.images setImageWithURL:[NSURL URLWithString:model.titleimage]];// NSLog(@"%d",indexPath.row); return cell;}#pragma mark-#pragma mark- collectionview点击事件- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ TwoHomepageViewController * two=[[TwoHomepageViewController alloc]init]; HomePageModel * model=[_collectionArray objectAtIndex:indexPath.row]; two.takeId=model.idNum; [self.navigationController pushViewController:two animated:YES]; two.hidesBottomBarWhenPushed = YES;//隐藏tabBar [two release];}
0 0
- UICollectionView 简单实现
- UICollectionView简单实现日历
- Swift实现最简单的UICollectionView
- UICollectionView的简单使用
- UICollectionView的简单创建
- iOS UICollectionView简单使用
- UICollectionView 简单使用
- iOS UICollectionView简单使用
- UICollectionView的简单使用
- UICollectionView简单示例
- UICollectionView的简单使用
- iOS UICollectionView简单使用
- iOS UICollectionView简单使用
- iOS UICollectionView简单使用
- UICollectionView 简单使用
- iOS---UICollectionView简单使用
- UICollectionView的简单使用
- UICollectionView的简单使用
- Spring的注解形式
- R-时间序列自相关acf,偏自相关pacf
- java中for循环的两种方式优劣
- memached+asp.net 4.0 分布式缓存
- POJ2785:4 Values whose Sum is 0(二分)
- UICollectionView 简单实现
- 详解 QT 中Graphics View柜架(下篇)
- dllimport与dllexport作用与区别
- 股份第三个何润东
- Nginx之超时管理(定时器事件)
- 【HDU】1534 Schedule Problem 差分约束
- SQL Joins
- JSP基础
- HowTo: Use grep Command In Linux / UNIX – Examples