MyMessageVC.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. //
  2. // MyMessageVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/9/15.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "MyMessageVC.h"
  9. #define normalCellH 44
  10. @interface MyMessageVC ()
  11. {
  12. NSArray *_keysArr;
  13. NSMutableArray *_statusArr;
  14. NSMutableArray *_heightsArr;
  15. }
  16. @end
  17. @implementation MyMessageVC
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. self.holderV.hidden = YES;
  21. _keysArr = @[@[@"登录账号",@"loginCode"],
  22. @[@"所在地市",@"dqmc,qxmc"],
  23. @[@"用户级别",@"userType"],//1省级,2市级,3.区级
  24. @[@"用户电话",@"tel"],
  25. @[@"创建用户",@"crUserName"],
  26. @[@"创建时间",@"crDate"]];
  27. _statusArr = [[NSMutableArray alloc]init];
  28. _heightsArr = [[NSMutableArray alloc]init];
  29. for (int i=0; i<_keysArr.count; i++) {
  30. [_statusArr addObject:@0];
  31. [_heightsArr addObject:@normalCellH];
  32. }
  33. }
  34. #pragma mark - tbv代理
  35. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  36. return _keysArr.count;
  37. }
  38. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  39. if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
  40. //缓存高度
  41. NSNumber *cellHeight = [_heightsArr objectAtIndex:indexPath.row];
  42. if ([cellHeight isEqualToNumber:@normalCellH]) {
  43. CGFloat fontSize = 17;
  44. NSString *detail = [NSString stringWithFormat:@"%@",MYAPPDELEGATE.userDic[_keysArr[indexPath.row][1]]];
  45. CGFloat wid = kSize.width - [_keysArr[indexPath.row][0] widthForFont:fontSize] - 46;//46是cell边距20+20+间距6 plus
  46. CGFloat h1 = [detail heightForWid:wid Font:fontSize]+1+16;//+1 cell与content 16是上下间距
  47. CGFloat H = h1>normalCellH?h1:normalCellH;
  48. [_heightsArr replaceObjectAtIndex:indexPath.row withObject:[NSNumber numberWithFloat:H]];
  49. return H;
  50. }else{
  51. return [cellHeight floatValue];
  52. }
  53. }
  54. return normalCellH;
  55. }
  56. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  57. UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cellId"];
  58. if (!cell) {
  59. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellId"];
  60. }
  61. if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
  62. cell.detailTextLabel.numberOfLines = 0;
  63. cell.detailTextLabel.textAlignment = NSTextAlignmentLeft;
  64. }else{
  65. cell.detailTextLabel.numberOfLines = 1;
  66. cell.detailTextLabel.textAlignment = NSTextAlignmentRight;
  67. }
  68. NSString * key = _keysArr[indexPath.row][1];
  69. cell.textLabel.text = _keysArr[indexPath.row][0];
  70. cell.detailTextLabel.numberOfLines = 0;
  71. if ([key isEqualToString:@"dqmc,qxmc"]){
  72. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@ %@",MYAPPDELEGATE.userDic[@"dqmc"],MYAPPDELEGATE.userDic[@"qxmc"]];
  73. }else if ([key isEqualToString:@"userType"]){
  74. NSString *status = [NSString stringWithFormat:@"%@",MYAPPDELEGATE.userDic[key]];
  75. //车牌颜色(1:蓝色; 2:黄色; 3:黑色; 4:白色; 5:绿色; 9:其他;)
  76. switch ([status integerValue]) {
  77. case 1:
  78. cell.detailTextLabel.text = @"省级";
  79. break;
  80. case 2:
  81. cell.detailTextLabel.text = @"市级";
  82. break;
  83. case 3:
  84. cell.detailTextLabel.text = @"区县级";
  85. break;
  86. }
  87. }else{
  88. cell.detailTextLabel.text = [NSString stringWithFormat:@"%@",MYAPPDELEGATE.userDic[key]];
  89. }
  90. cell.textLabel.text = _keysArr[indexPath.row][0];
  91. return cell;
  92. }
  93. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  94. if ([_statusArr[indexPath.row] isEqualToNumber:@1]) {
  95. [_statusArr replaceObjectAtIndex:indexPath.row withObject:@0];
  96. }else{
  97. [_statusArr replaceObjectAtIndex:indexPath.row withObject:@1];
  98. }
  99. [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
  100. }
  101. - (void)didReceiveMemoryWarning {
  102. [super didReceiveMemoryWarning];
  103. // Dispose of any resources that can be recreated.
  104. }
  105. /*
  106. #pragma mark - Navigation
  107. // In a storyboard-based application, you will often want to do a little preparation before navigation
  108. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  109. // Get the new view controller using [segue destinationViewController].
  110. // Pass the selected object to the new view controller.
  111. }
  112. */
  113. @end