Advertisement
r_levkovych

Footer-not loading

Jun 12th, 2020
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @interface Footer : UITableViewHeaderFooterView
  2.  
  3. @property (nonatomic, strong)           UIButton *moreData;
  4.  
  5. @end
  6.  
  7. @implementation Footer
  8.  
  9. - (instancetype)initWithFrame:(CGRect)frame
  10. {
  11.     self = [super initWithFrame:frame];
  12.     if (self) {
  13.         self.moreData = [[UIButton alloc] initWithFrame:frame];
  14.         [self configureFooter];
  15.     }
  16.     return self;
  17. }
  18.  
  19. - (void)configureFooter {
  20.     self.moreData.translatesAutoresizingMaskIntoConstraints = NO;
  21.  
  22.     // setup title: bold big underlined text
  23. //    var title = [[NSMutableAttributedString alloc] initWithString: @"NORIU DAUGIAU GB" ];
  24. //
  25. //    [title beginEditing];
  26. //    [title addAttribute:NSUnderlineStyleAttributeName
  27. //                  value:[NSNumber numberWithInt:1]
  28. //                  range:(NSRange){0,[title length]}];
  29. //    [title addAttribute:NSFontAttributeName value:kBigFont range:(NSRange){0, [title length]}];
  30. //    [title endEditing];
  31. //
  32. //    self.moreData.titleLabel.attributedText = title;
  33.     [self.contentView addSubview:self.moreData];
  34.  
  35.     // the whole footer is a button with text "more gigabytes"
  36.     [NSLayoutConstraint activateConstraints:@[
  37.         [self.moreData.leadingAnchor constraintEqualToAnchor:self.contentView.leadingAnchor],
  38.         [self.moreData.trailingAnchor constraintEqualToAnchor:self.contentView.trailingAnchor],
  39.         [self.moreData.topAnchor constraintEqualToAnchor:self.contentView.topAnchor],
  40.         [self.moreData.bottomAnchor constraintEqualToAnchor:self.contentView.bottomAnchor],
  41.     ]];
  42.     self.moreData.backgroundColor = [UIColor yellowColor];
  43.     self.moreData.titleLabel.text = @"TEXT";
  44.     self.moreData.titleLabel.textColor = kPrimaryBlack;
  45. }
  46.  
  47. @end
  48.  
  49.  
  50. /// inside vc
  51.  
  52. @implementation VC
  53.  
  54. - (void)viewDidLoad {
  55.     [super viewDidLoad];
  56.     footer = [[Footer alloc]
  57.               initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 75.f)];
  58.     [footer.moreData addTarget:self action:@selector(removeFooter) forControlEvents:UIControlEventTouchUpInside];
  59.     self.tableView.tableFooterView = footer;
  60. }
  61.  
  62. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement