IOS 开发小记 ————————collection view 总结
来源:互联网 发布:卡通农场mac版 编辑:程序博客网 时间:2024/05/01 02:52
2 拖一个collection 到 controller 中
3 修改其中默认的一个cellview 加入 imageview 和 label
然后新建一个viewcontroller 和 cellview 对接 ,在storyboard 把ID 设为 对应的viewcontroller 的名字
4 使用collection 的controller 需要 . h中 实现两个接口
#import <UIKit/UIKit.h>@interface Test1ViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegate>@property (strong, nonatomic)NSMutableArray *dataMArr;@property (weak, nonatomic) IBOutlet UICollectionView *mkconllection;@end
5 对应的实现 :
- (void)viewDidLoad {
[superviewDidLoad];
[selfsetUpCollection];
// Do any additional setup after loading the view.
}
-(void)setUpCollection{
self.dataMArr = [NSMutableArrayarray];
for(NSInteger index =0;index<9; index++){
UIImage *image = [UIImageimageNamed:[NSStringstringWithFormat:@"%ld",(long)index+1]];
NSString *title = [NSStringstringWithFormat:@"{0,%ld}",(long)index+1];
NSDictionary *dic = @{@"image": image, @"title":title};
[self.dataMArraddObject:dic];
}
self.mkconllection.delegate =self;
self.mkconllection.dataSource =self;
}
#pragma mark - Collection View Data Source
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.dataMArr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *collectionCellID =@"myCollectionCell";
collectionCellmk *cell = (collectionCellmk *)[collectionViewdequeueReusableCellWithReuseIdentifier:collectionCellIDforIndexPath:indexPath];
NSDictionary *dic = self.dataMArr[indexPath.row];
UIImage *image = dic[@"image"];
NSString *title = dic[@"title"];
cell.CellImage.image = image;
cell.celllabel.text = title;
return cell;
};
static NSString *collectionCellID = @"myCollectionCell";
collectionCellmk *cell = (collectionCellmk *)[collectionViewdequeueReusableCellWithReuseIdentifier:collectionCellIDforIndexPath:indexPath];
2 如果崩溃无法找issue ui 有可能是 连接太多出的问题
- IOS 开发小记 ————————collection view 总结
- 《iOS Human Interface Guidelines》——Collection View
- iOS开发——ARC小记
- 面试小记1——IOS开发工程师
- 面试小记2——IOS开发工程师
- 面试小记3——IOS开发工程师
- 面试小记4——IOS开发工程师
- iOS开发——view内缩弹窗
- iOS开发之自定义view—Quartz2D
- Android开发 —— 自定义View总结
- Django学习小记[5] —— View Request/Response
- Django学习小记[6]——Class-based View
- IOS 开发笔记——如何用 collection 创建瀑布流
- IOS开发之——自定义的Activity Indicator View
- IOS开发之——自定义的Activity Indicator View
- iOS开发UI篇—控制器的View的创建
- iOS开发UI篇—控制器的View的创建
- IOS开发—通过ChildViewController实现view的切换
- Eclipse RCP - 第一个RCP程序
- 《弟子规》全集译文,为孩子的明天存下来!
- 图片优化时注意的小问题
- scrapy抓取动态页面的事项
- REDIS缓存技术
- IOS 开发小记 ————————collection view 总结
- poj 1190 生日蛋糕
- Golang之bytes.buffer
- windows下使用ElasticSearch数据库-入门
- Java 实现的各种经典的排序算法小Demo
- matlab中sum(,3)求和函数
- IPython Notebook 的安装方法
- 关于android端的json传输
- 小知识点4