AccountAndSecurityViewController.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // AccountAndSecurityViewController.m
  3. // ChinaTheoryNetwork
  4. //
  5. // Created by 张毅成 on 2019/1/28.
  6. // Copyright © 2019 张毅成. All rights reserved.
  7. //
  8. #import "AccountAndSecurityViewController.h"
  9. #import "AccountAndSecurityModel.h"
  10. #import "AccountAndSecurityTableViewCell.h"
  11. #import "ReplacePhoneNumberViewController.h"
  12. @interface AccountAndSecurityViewController ()<UITableViewDataSource, UITableViewDelegate>
  13. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  14. /**
  15. */
  16. @property (strong, nonatomic) AccountAndSecurityModel *model;
  17. @end
  18. @implementation AccountAndSecurityViewController
  19. - (AccountAndSecurityModel *)model {
  20. if (!_model) {
  21. _model = [AccountAndSecurityModel new];
  22. }
  23. return _model;
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.title = @"账号与安全";
  28. self.view.backgroundColor = kBackgroundColor;
  29. [self createTableView];
  30. }
  31. - (void)createTableView {
  32. self.tableView.delegate = self;
  33. self.tableView.dataSource = self;
  34. self.tableView.tableFooterView = [UIView new];
  35. self.tableView.rowHeight = UITableViewAutomaticDimension;
  36. self.tableView.estimatedRowHeight = 60;
  37. // self.tableView.separatorStyle = 0;
  38. self.tableView.backgroundColor = kBackgroundColor;
  39. }
  40. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  41. UIView *view = [UIView new];
  42. [view setBackgroundColor:kBackgroundColor];
  43. return view;
  44. }
  45. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  46. UIView *view = [UIView new];
  47. [view setBackgroundColor:kBackgroundColor];
  48. return view;
  49. }
  50. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  51. return 10;
  52. }
  53. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  54. return 10;
  55. }
  56. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  57. return 1;
  58. }
  59. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  60. return AccountAndSecurityModel.arrayData.count;
  61. }
  62. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  63. AccountAndSecurityTableViewCell *cell = [AccountAndSecurityTableViewCell cellWithTableView:tableView];
  64. cell.labelTItle.text = AccountAndSecurityModel.arrayData[indexPath.row];
  65. if (indexPath.row == 0) {
  66. cell.labelDetail.text = self.modelMy.nickname;
  67. }else
  68. cell.labelDetail.text = self.modelMy.mobile;
  69. return cell;
  70. }
  71. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  72. ReplacePhoneNumberViewController *controller = [ReplacePhoneNumberViewController new];
  73. controller.modelMy = self.modelMy;
  74. [self.navigationController pushViewController:controller animated:true];
  75. }
  76. - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  77. if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
  78. [cell setSeparatorInset:UIEdgeInsetsZero];
  79. }
  80. if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
  81. [cell setLayoutMargins:UIEdgeInsetsZero];
  82. }
  83. if([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) {
  84. [cell setPreservesSuperviewLayoutMargins:NO];
  85. }
  86. }
  87. @end