iOS collectionView 单选/多选(横向纵向),高
2019-08-13 本文已影响0人
iOS门三闫
之前项目中有遇到过collectionview的单选,多选等,有的时候还要求横向滑动单选,多选功能,最近不是太忙,总结到一块了,包括横向滑动单选,横向滑动多选,纵向展示单选,纵向展示多选,纵向的时候高度可自适应。代码调用比较简单,遵循下协议就可以。有需要的小伙伴可以下载demo共同学习下。
1.初始化
CustomHorizontalSingleSelectView *custom = [[CustomHorizontalSingleSelectView alloc] initWithFrame:CGRectMake(0, 100, self.view.frame.size.width, 150)];
custom.imageArr= [arraymutableCopy];
//默认选中index
custom.selectIndex=0;
custom.Delegate=self;
[self.custom];
2.点击方法调用
- (void)clickBtnHorizontalSingle:(NSInteger)index select:(NSString*)selectImgID selectImgUrl:(NSString*)selectImgUrl {
NSLog(@"2当前点击图片index-----%ld ------ 选中图片id%@------选中图片地址url%@",index,selectImgID,selectImgUrl);
}
3.效果图

