PDFSettingsValueViewController.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // PDFSettingsValueViewController.m
  3. // PDFReader
  4. //
  5. // Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
  6. //
  7. // The PDF Reader Sample applications are licensed with a modified BSD license.
  8. // Please see License for details. This notice may not be removed from this file.
  9. //
  10. #import "PDFSettingsValueViewController.h"
  11. @interface PDFSettingsValueViewController () <UITableViewDelegate,UITableViewDataSource>
  12. @property (nonatomic,retain) UITableView *tableView;
  13. @end
  14. @implementation PDFSettingsValueViewController
  15. #pragma mark - Init Methods
  16. - (instancetype)init {
  17. if (self = [super init]) {
  18. }
  19. return self;
  20. }
  21. - (void)dealloc {
  22. if (_callback) {
  23. Block_release(_callback);
  24. _callback = nil;
  25. }
  26. [_tableView release];
  27. [super dealloc];
  28. }
  29. #pragma mark - UIViewController Methods
  30. - (void)viewDidLoad {
  31. [super viewDidLoad];
  32. // Do any additional setup after loading the view.
  33. self.tableView = [[[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped] autorelease];
  34. self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  35. self.tableView.delegate = self;
  36. self.tableView.dataSource = self;
  37. [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
  38. [self.view addSubview:self.tableView];
  39. }
  40. #pragma mark - UITableViewDataSource
  41. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  42. return 1;
  43. }
  44. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  45. return self.dataSource.count;
  46. }
  47. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  48. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
  49. cell.textLabel.text = self.dataSource[indexPath.row];
  50. if (self.selectedIndex == indexPath.row) {
  51. cell.accessoryType = UITableViewCellAccessoryCheckmark;
  52. } else {
  53. cell.accessoryType = UITableViewCellAccessoryNone;
  54. }
  55. return cell;
  56. }
  57. #pragma mark - UITableViewDelegate
  58. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  59. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  60. self.selectedIndex = indexPath.row;
  61. [tableView reloadData];
  62. if (self.callback) {
  63. self.callback(indexPath.row);
  64. self.callback = nil;
  65. }
  66. [self.navigationController popViewControllerAnimated:YES];
  67. }
  68. @end