BogoDTHeadView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // BogoDTHeadView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/5/6.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoDTHeadView.h"
  9. #import "BogoDTHeadCell.h"
  10. #import "BGTopicTimeLineListController.h"
  11. @implementation BogoDTHeadView
  12. - (instancetype)initWithFrame:(CGRect)frame
  13. {
  14. self = [super initWithFrame:frame];
  15. if (self) {
  16. [self setUpView];
  17. }
  18. return self;
  19. }
  20. - (void)awakeFromNib{
  21. [super awakeFromNib];
  22. [self setUpView];
  23. }
  24. -(void)setUpView{
  25. [self.collectionView registerNib:[UINib nibWithNibName:@"BogoDTHeadCell" bundle:nil] forCellWithReuseIdentifier:@"BogoDTHeadCell"];
  26. self.collectionView.backgroundColor = kClearColor;
  27. self.collectionView.delegate = self;
  28. self.collectionView.dataSource = self;
  29. }
  30. -(void)resetTopicModel:(NSArray *)arr{
  31. self.listArr = [NSMutableArray arrayWithArray:arr];
  32. [self.collectionView reloadData];
  33. // for (int i = 0; i < 4; i ++) {
  34. // if (i > 4) return;
  35. // MGNewDTHeadControl *control = [self.topicView viewWithTag:100 + i];
  36. //
  37. // if(arr.count > i)
  38. // {
  39. // [control resetControlModel:arr[i]];
  40. // //给有数据的view添加手势
  41. // [control addTarget:self action:@selector(MGNewDTHeadAction:) forControlEvents:UIControlEventTouchUpInside];
  42. // }
  43. // }
  44. }
  45. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  46. return 1;
  47. }
  48. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  49. return self.listArr.count;
  50. }
  51. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  52. BogoDTHeadCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BogoDTHeadCell" forIndexPath:indexPath];
  53. cell.backgroundColor = kClearColor;
  54. [cell resetControlModel:self.listArr[indexPath.row]];
  55. return cell;
  56. }
  57. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  58. BGTopicTimeLineListController *pushVC = [BGTopicTimeLineListController new];
  59. // if (self.logic.topicArr.count > index - 1) {
  60. pushVC.topic = self.listArr[indexPath.row];
  61. // self.logic.topicArr[index];
  62. [[AppDelegate sharedAppDelegate]pushViewController:pushVC animated:YES];
  63. }
  64. //- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
  65. //{
  66. //
  67. // return CGSizeMake((kScreenW-30)/2.0f, (kScreenW-30) / 2.0f + kRealValue(30));
  68. //}
  69. //
  70. //- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  71. //
  72. // return 10;
  73. //}
  74. //
  75. //- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  76. //
  77. // return 0;
  78. //}
  79. //
  80. //- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
  81. //{
  82. // return UIEdgeInsetsMake(10, 10, 0, 10);
  83. //}
  84. @end