MACBaseCell.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // MACBaseCell.h
  3. // MACProject
  4. //
  5. // Created by MacKun on 15/12/18.
  6. // Copyright © 2015年 MacKun. All rights reserved.
  7. //
  8. #import "MACBaseCell.h"
  9. //#import "POP.h"
  10. @interface MACBaseCell()
  11. @property (nonatomic, strong) UIView *line;
  12. @end
  13. @implementation MACBaseCell
  14. -(instancetype)initWithCoder:(NSCoder *)aDecoder{
  15. if (self = [super initWithCoder:aDecoder]) {
  16. [self setupCell];
  17. [self buildSubview];
  18. }
  19. return self;
  20. }
  21. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  22. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  23. [self setupCell];
  24. [self buildSubview];
  25. }
  26. return self;
  27. }
  28. - (void)setupCell {
  29. self.selectionStyle=UITableViewCellSelectionStyleNone;
  30. }
  31. - (void)buildSubview {
  32. //DLog(@"appLine");
  33. // self.line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 0.5f)];
  34. // self.line.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.5f];
  35. // //self.line.tag=1;
  36. // [self.contentView addSubview:self.line];
  37. }
  38. - (void)loadContent {
  39. }
  40. - (void)selectedEvent {
  41. }
  42. + (CGFloat)cellHeightWithData:(id)data {
  43. return 0.f;
  44. }
  45. -(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
  46. [super setHighlighted:highlighted animated:animated];
  47. // if (self.highlighted) {
  48. // POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewScaleXY];
  49. // scaleAnimation.duration = 0.1f;
  50. // scaleAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.99, 0.99)];
  51. // [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
  52. //
  53. // } else {
  54. //
  55. // POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
  56. // scaleAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1, 1)];
  57. // scaleAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(1.5, 1.5)];
  58. // scaleAnimation.springBounciness = 10.f;
  59. // [self pop_addAnimation:scaleAnimation forKey:@"scaleAnimation"];
  60. // }
  61. }
  62. - (void)setWeakReferenceWithCellDataAdapter:(CellDataAdapter *)dataAdapter data:(id)data
  63. indexPath:(NSIndexPath *)indexPath tableView:(UITableView *)tableView {
  64. _dataAdapter = dataAdapter;
  65. _data = data;
  66. _indexPath = indexPath;
  67. _tableView = tableView;
  68. }
  69. + (CellDataAdapter *)dataAdapterWithCellReuseIdentifier:(NSString *)reuseIdentifier data:(id)data cellHeight:(CGFloat)height type:(NSInteger)type {
  70. NSString *tmpReuseIdentifier = reuseIdentifier.length <= 0 ? NSStringFromClass([self class]) : reuseIdentifier;
  71. return [CellDataAdapter cellDataAdapterWithCellReuseIdentifier:tmpReuseIdentifier data:data cellHeight:height cellType:type];
  72. }
  73. + (CellDataAdapter *)dataAdapterWithCellReuseIdentifier:(NSString *)reuseIdentifier data:(id)data
  74. cellHeight:(CGFloat)height cellWidth:(CGFloat)cellWidth
  75. type:(NSInteger)type {
  76. NSString *tmpReuseIdentifier = reuseIdentifier.length <= 0 ? NSStringFromClass([self class]) : reuseIdentifier;
  77. return [CellDataAdapter cellDataAdapterWithCellReuseIdentifier:tmpReuseIdentifier data:data cellHeight:height cellWidth:cellWidth cellType:type];
  78. }
  79. + (CellDataAdapter *)dataAdapterWithData:(id)data cellHeight:(CGFloat)height type:(NSInteger)type {
  80. return [CellDataAdapter cellDataAdapterWithCellReuseIdentifier:nil data:data cellHeight:height cellType:type];
  81. }
  82. + (CellDataAdapter *)dataAdapterWithData:(id)data cellHeight:(CGFloat)height {
  83. return [CellDataAdapter cellDataAdapterWithCellReuseIdentifier:nil data:data cellHeight:height cellType:0];
  84. }
  85. + (CellDataAdapter *)dataAdapterWithData:(id)data {
  86. return [CellDataAdapter cellDataAdapterWithCellReuseIdentifier:nil data:data cellHeight:0 cellType:0];
  87. }
  88. - (void)updateWithNewCellHeight:(CGFloat)height animated:(BOOL)animated {
  89. if (_tableView && _dataAdapter) {
  90. if (animated) {
  91. _dataAdapter.cellHeight = height;
  92. [_tableView beginUpdates];
  93. [_tableView endUpdates];
  94. } else {
  95. _dataAdapter.cellHeight = height;
  96. [_tableView reloadData];
  97. }
  98. }
  99. }
  100. @end