CPDFBookmarkViewCell.m 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // CPDFBookmarkViewCell.m
  3. // ComPDFKit_Tools
  4. //
  5. // Copyright © 2014-2024 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  8. // AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  9. // UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  10. //
  11. #import "CPDFBookmarkViewCell.h"
  12. @interface CPDFBookmarkViewCell()
  13. @property (nonatomic, strong) UIView * bottomView;
  14. @end
  15. @implementation CPDFBookmarkViewCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  17. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  18. _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 5, self.bounds.size.width - 110, self.bounds.size.height - 10)];
  19. _titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  20. _pageIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 100, 5, 85, self.bounds.size.height - 10)];
  21. _pageIndexLabel.textAlignment = NSTextAlignmentRight;
  22. _pageIndexLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight;
  23. _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - 1, self.bounds.size.width, 1)];
  24. _bottomView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1];
  25. _bottomView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
  26. [self.contentView addSubview:self.titleLabel];
  27. [self.contentView addSubview:self.pageIndexLabel];
  28. [self.contentView addSubview:_bottomView];
  29. }
  30. return self;
  31. }
  32. - (void)awakeFromNib {
  33. [super awakeFromNib];
  34. // Initialization code
  35. }
  36. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  37. [super setSelected:selected animated:animated];
  38. // Configure the view for the selected state
  39. }
  40. #pragma mark - Action
  41. - (void)buttonItemClicked_edit:(id)sender {
  42. UITableView *tableView = [self getTableView];
  43. if (tableView) {
  44. NSIndexPath *indexPath = [tableView indexPathForCell:self];
  45. [tableView setEditing:YES animated:YES];
  46. [tableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle];
  47. }
  48. }
  49. - (UITableView *)getTableView {
  50. UIView *tableView = self.superview;
  51. while (![tableView isKindOfClass:[UITableView class]] && tableView != nil) {
  52. tableView = tableView.superview;
  53. }
  54. return (UITableView *)tableView;
  55. }
  56. @end