mySuggestVC.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // mySuggestVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/5/4.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "mySuggestVC.h"
  9. #import "HolderView.h"
  10. #import "FaqCell.h"
  11. @interface mySuggestVC ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. UITableView *mainTableView;
  14. HolderView *holderV;
  15. NSArray *dataArray;
  16. }
  17. @end
  18. @implementation mySuggestVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.title = @"其它建议";
  22. self.view.backgroundColor = [UIColor whiteColor];
  23. [self configNavigationBar];
  24. dataArray = [NSArray array];
  25. mainTableView = [[UITableView alloc] initWithFrame:kFrame style:UITableViewStyleGrouped];
  26. mainTableView.height -= kNavOffSet;
  27. mainTableView.delegate = self;
  28. mainTableView.dataSource = self;
  29. mainTableView.estimatedSectionHeaderHeight = 0;
  30. mainTableView.estimatedSectionFooterHeight = 0;
  31. [self.view addSubview:mainTableView];
  32. holderV = [[HolderView alloc] initWithFrame:mainTableView.frame];
  33. [holderV freshBlock:^{
  34. [self getMySuggestReply];
  35. }];
  36. [self.view addSubview:holderV];
  37. [self getMySuggestReply];
  38. }
  39. #pragma mark maintableview delegate
  40. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  41. {
  42. return dataArray.count;;
  43. }
  44. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  45. {
  46. return 1;
  47. }
  48. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  49. {
  50. FaqCell* cell = [FaqCell cellForTableView:tableView];
  51. [cell setSuggestModel:dataArray[indexPath.section]];
  52. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  53. return cell;
  54. }
  55. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  56. {
  57. NSDictionary *dic = dataArray[indexPath.section];
  58. CGFloat h1 = [dic[@"ANSWERCONTENT"] heightForWid:kSize.width - 80 Font:14];
  59. if (h1 < 25) {
  60. h1 = 25;
  61. }
  62. CGFloat h2 = [dic[@"REPLYCONTENT"] heightForWid:kSize.width - 80 Font:14];
  63. if (h2 < 25) {
  64. h2 = 25;
  65. }
  66. return h1 + h2 + 90;
  67. }
  68. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
  69. {
  70. if (0 == section) {
  71. return .1;
  72. }else{
  73. return 20;
  74. }
  75. }
  76. -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  77. {
  78. return .1;
  79. }
  80. #pragma mark 数据请求
  81. -(void)getMySuggestReply
  82. {
  83. if (![Util connectedToNetWork]) {
  84. return;
  85. }
  86. NSMutableArray *arr=[NSMutableArray array];
  87. [arr addPro:@"user" Value:defUser.userDict[@"id"]];
  88. NSString* method = @"getMySuggestReply";
  89. [MBProgressHUD showLoadToView:self.view];
  90. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
  91. [MBProgressHUD hideHUDForView:self.view];
  92. [holderV setHidden:NO];
  93. if (!root) {
  94. [LoadingView showMsg:@"查询失败"];
  95. return;
  96. }
  97. NSString* code = root[@"code"];
  98. if (code.intValue >0)
  99. {
  100. [LoadingView showMsg:root[@"body"]];
  101. return;
  102. }
  103. if ([root[@"body"] count] < 1) {
  104. return;
  105. }
  106. dataArray = root[@"body"];
  107. [holderV setHidden:YES];
  108. [mainTableView reloadData];
  109. }];
  110. }
  111. - (void)didReceiveMemoryWarning {
  112. [super didReceiveMemoryWarning];
  113. // Dispose of any resources that can be recreated.
  114. }
  115. @end