PictureFileViewController.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // PictureFileViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2018/11/13.
  6. // Copyright © 2018年 XM. All rights reserved.
  7. //
  8. #import "PictureFileViewController.h"
  9. #import "PictureSearchViewController.h"
  10. #import "MonthPictureViewController.h"
  11. #import "ItemTableviewCell.h"
  12. #import "Header.h"
  13. @interface PictureFileViewController () <UITableViewDelegate,UITableViewDataSource>
  14. {
  15. UITableView *tableV;
  16. NSMutableArray *titleArray;
  17. }
  18. @end
  19. @implementation PictureFileViewController
  20. - (void)viewDidLoad {
  21. [super viewDidLoad];
  22. //初始化tableview数据
  23. [self initDataSource];
  24. [self configSubView];
  25. }
  26. #pragma mark - tableView代理方法
  27. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  28. return titleArray.count;
  29. }
  30. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  31. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  32. if (!cell) {
  33. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  34. }
  35. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  36. NSString *title = [titleArray objectAtIndex:indexPath.row];
  37. cell.textLabel.text = title;
  38. return cell;
  39. }
  40. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  41. NSString *titleStr = titleArray[indexPath.row];
  42. if ([titleStr isEqualToString:TS("search_picture")]) {
  43. PictureSearchViewController *picSearchVC = [[PictureSearchViewController alloc] init];
  44. [self.navigationController pushViewController:picSearchVC animated:YES];
  45. }else if ([titleStr isEqualToString:TS("search_picture_date")]) {
  46. MonthPictureViewController *MonthFileVC = [[MonthPictureViewController alloc] init];
  47. [self.navigationController pushViewController:MonthFileVC animated:YES];
  48. }
  49. }
  50. #pragma mark - 界面和数据初始化
  51. - (void)configSubView {
  52. [self.view addSubview:self.tableV];
  53. }
  54. - (UITableView *)tableV {
  55. if (!tableV) {
  56. tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  57. tableV.delegate = self;
  58. tableV.dataSource = self;
  59. [tableV registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  60. }
  61. return tableV;
  62. }
  63. #pragma mark - 界面和数据初始化
  64. - (void)initDataSource {
  65. titleArray = (NSMutableArray*)@[TS("search_picture"),TS("search_picture_date")];
  66. }
  67. - (void)didReceiveMemoryWarning {
  68. [super didReceiveMemoryWarning];
  69. // Dispose of any resources that can be recreated.
  70. }
  71. @end