YOUPAIZYUserZiLiaoGRXXCell.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // YOUPAIZYUserZiLiaoDTCell.m
  3. // VQU
  4. //
  5. // Created by 肖浩然的mac on 2021/7/10.
  6. // Copyright © 2021 leo. All rights reserved.
  7. //
  8. #import "YOUPAIZYUserZiLiaoGRXXCell.h"
  9. #import "YOUPAIZYUserZiLiaoGRXXContentCell.h"
  10. #import "YOUPAILCDynamicArrayModel.h"
  11. #import "YOUPAILCUserShowModel.h"
  12. @interface YOUPAIZYUserZiLiaoGRXXCell()<UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
  13. @property (nonatomic, strong) UICollectionView *youpaipcollectionView;
  14. @end
  15. @implementation YOUPAIZYUserZiLiaoGRXXCell
  16. -(instancetype)initWithFrame:(CGRect)frame{
  17. if (self = [super initWithFrame:frame]) {
  18. [self youpaifsetSubView];
  19. }
  20. return self;
  21. }
  22. -(void)youpaifsetSubView{
  23. UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
  24. flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
  25. self.youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
  26. [self.contentView addSubview:self.youpaipcollectionView];
  27. [self.youpaipcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.top.mas_equalTo(9);
  29. make.left.mas_offset(12.f);
  30. make.right.mas_offset(-12);
  31. make.bottom.mas_offset(0.f);
  32. }];
  33. self.youpaipcollectionView.backgroundColor = [UIColor whiteColor];
  34. self.youpaipcollectionView.showsVerticalScrollIndicator = NO;
  35. self.youpaipcollectionView.showsHorizontalScrollIndicator = NO;
  36. self.youpaipcollectionView.bounces = NO;
  37. [self.youpaipcollectionView registerClass:[YOUPAIZYUserZiLiaoGRXXContentCell class] forCellWithReuseIdentifier:NSStringFromClass([YOUPAIZYUserZiLiaoGRXXContentCell class])];
  38. self.youpaipcollectionView.delegate = self;
  39. self.youpaipcollectionView.dataSource = self;
  40. }
  41. -(void)setYoupaipalbumArray:(NSArray *)albumArray{
  42. }
  43. #pragma mark <UICollectionViewDataSource>
  44. /**
  45. 返回区数
  46. @param collectionView 集合视图
  47. @return 返回区数
  48. */
  49. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  50. return 1;
  51. }
  52. /**
  53. 返回项目数
  54. @param collectionView 集合视图
  55. @param section 区
  56. @return 项目数
  57. */
  58. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  59. return self.youpaipaArr.count;
  60. }
  61. -(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  62. // NSString *imageUrl = self.albumArray[indexPath.item];
  63. YOUPAIZYUserZiLiaoGRXXContentCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YOUPAIZYUserZiLiaoGRXXContentCell class]) forIndexPath:indexPath];
  64. YOUPAIBasicInfo *model = self.youpaipaArr[indexPath.item];
  65. cell.youpaiTitle.text = model.youpaiptitle;
  66. cell.youpaiContent.text = model.youpaipvalue;
  67. if ([model.youpaiptitle isEqualToString:@"性别"]) {
  68. if ([model.youpaipvalue isEqualToString:@"1"]) {
  69. cell.youpaiContent.text = @"女";
  70. }else{
  71. cell.youpaiContent.text = @"男";
  72. }
  73. }
  74. if (self.youpaipaArr.count == indexPath.item+1) {
  75. cell.youpaicopyBtn.hidden = NO;
  76. }else{
  77. cell.youpaicopyBtn.hidden = YES;
  78. }
  79. return cell;
  80. }
  81. -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  82. if ([self.youpaipdelegate respondsToSelector:@selector(youpaifGRXXDidCellOrBtnclick)]) {
  83. [self.youpaipdelegate youpaifGRXXDidCellOrBtnclick];
  84. }
  85. YOUPAIBasicInfo *model = self.youpaipaArr[indexPath.item];
  86. if (self.youpaipaArr.count == indexPath.item+1) {
  87. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
  88. pasteboard.string = model.youpaipvalue;
  89. [ZCHUDHelper showTitle:@"复制成功,快去粘贴吧!"];
  90. }
  91. }
  92. #pragma mark UICollectionViewDelegateFlowLayout
  93. /**
  94. 项目大小
  95. @param collectionView 集合视图
  96. @param collectionViewLayout 布局
  97. @param indexPath 布局
  98. @return 大小
  99. */
  100. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  101. return CGSizeMake(111, 49);
  102. }
  103. #pragma mark - X间距
  104. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  105. return 9.0;
  106. }
  107. //设置段落的内边距
  108. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  109. {
  110. return UIEdgeInsetsMake(0,0,9,0);//UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right)
  111. }
  112. @end