CloudPhotoViewController.mm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // CloudPhotoViewController.m
  3. // FunSDKDemo
  4. //
  5. // Created by XM on 2019/1/3.
  6. // Copyright © 2019年 XM. All rights reserved.
  7. //
  8. #import "CloudPhotoViewController.h"
  9. #import "CloudphotoDayVController.h"
  10. #import "CloudPhotoConfig.h"
  11. #import "ItemTableviewCell.h"
  12. #import "Header.h"
  13. @interface CloudPhotoViewController () <UITableViewDelegate,UITableViewDataSource,CloudPhotoConfigDelegate>
  14. {
  15. CloudPhotoConfig * config;
  16. UITableView *tableV;
  17. NSMutableArray *titleArray;
  18. }
  19. @end
  20. @implementation CloudPhotoViewController
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. //初始化tableview数据
  24. [self initDataSource];
  25. [self configSubView];
  26. [self getPictureFileConfig];
  27. }
  28. - (void)viewWillDisappear:(BOOL)animated{
  29. //有加载状态、则取消加载
  30. if ([SVProgressHUD isVisible]){
  31. [SVProgressHUD dismiss];
  32. }
  33. }
  34. #pragma mark - 查询设备图片信息
  35. - (void)getPictureFileConfig {
  36. [SVProgressHUD showWithStatus:TS("")];
  37. if (config == nil) {
  38. config = [[CloudPhotoConfig alloc] init];
  39. config.delegate = self;
  40. }
  41. //调用查询这个月内哪些天有图片的接口,可以自己设置日期进行查询
  42. [config getCloudPhotoMonth:[NSDate date]];
  43. }
  44. #pragma mark 获取摄像机参数代理回调
  45. - (void)getCloudMonthResult:(NSInteger)result {
  46. if (result >= 0) {
  47. [SVProgressHUD dismiss];
  48. titleArray =[[config getMonthPictureArray] mutableCopy];
  49. //成功,刷新界面数据
  50. [self.tableV reloadData];
  51. }else{
  52. [MessageUI ShowErrorInt:(int)result];
  53. }
  54. }
  55. #pragma mark - tableView代理方法
  56. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  57. return titleArray.count;
  58. }
  59. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  60. ItemTableviewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemTableviewCell"];
  61. if (!cell) {
  62. cell = [[ItemTableviewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ItemTableviewCell"];
  63. }
  64. //当前月份包含云图片的日期
  65. NSString *dateString = [titleArray objectAtIndex:indexPath.row];
  66. cell.textLabel.text = dateString;
  67. cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  68. cell.textLabel.numberOfLines = 0;
  69. cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  70. return cell;
  71. }
  72. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  73. CloudphotoDayVController *cloudDayPhotoVC = [[CloudphotoDayVController alloc] init];
  74. cloudDayPhotoVC.dateStr = [titleArray objectAtIndex:indexPath.row];
  75. [self.navigationController pushViewController:cloudDayPhotoVC animated:YES];
  76. }
  77. #pragma mark - 界面和数据初始化
  78. - (void)configSubView {
  79. self.title = TS("search_picture_date");
  80. [self.view addSubview:self.tableV];
  81. }
  82. - (UITableView *)tableV {
  83. if (!tableV) {
  84. tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight ) style:UITableViewStylePlain];
  85. tableV.delegate = self;
  86. tableV.dataSource = self;
  87. [tableV registerClass:[ItemTableviewCell class] forCellReuseIdentifier:@"ItemTableviewCell"];
  88. }
  89. return tableV;
  90. }
  91. #pragma mark - 界面和数据初始化
  92. - (void)initDataSource {
  93. titleArray = [[NSMutableArray alloc] initWithCapacity:0];
  94. }
  95. - (void)didReceiveMemoryWarning {
  96. [super didReceiveMemoryWarning];
  97. // Dispose of any resources that can be recreated.
  98. }
  99. @end