酷店

KDPSetViewController.m 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. //
  2. // KDPSetViewController.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/9.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPSetViewController.h"
  9. #import "KDPPhoneLoginViewController.h"
  10. #import "KDPTabBarVC.h"
  11. @interface KDPSetViewController ()<UITableViewDelegate,UITableViewDataSource>
  12. {
  13. }
  14. @property(nonatomic,strong)UITableView *setView;
  15. @end
  16. @implementation KDPSetViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
  20. self.navBar.navTitleLabel.text=@"设置";
  21. self.view.backgroundColor=[UIColor colorWithHexString:LineColor];
  22. [self.view addSubview:self.setView];
  23. [self.setView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.top.mas_equalTo(KDNavBarHeight);
  25. make.left.right.mas_equalTo(0);
  26. make.bottom.mas_equalTo(self.view.mas_bottom).offset(-50);
  27. }];
  28. UIButton *exitButton=[[UIButton alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50, SCREEN_WIDTH, 50)];
  29. [exitButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
  30. [exitButton setTitle:@"退出登录" forState:UIControlStateNormal];
  31. exitButton.titleLabel.font=[UIFont systemFontOfSize:14];
  32. [exitButton addTarget:self action:@selector(exitClickButton) forControlEvents:UIControlEventTouchUpInside];
  33. exitButton.backgroundColor=[UIColor whiteColor];
  34. [self.view addSubview:exitButton];
  35. }
  36. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  37. {
  38. UITableViewCell *listC=[tableView dequeueReusableCellWithIdentifier:@"set"];
  39. if (!listC) {
  40. listC=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"set"];
  41. listC.selectionStyle=UITableViewCellSelectionStyleNone;
  42. }
  43. KDPAccountModel *model =[KDPAccountTool account];
  44. listC.textLabel.text=@"我的手机号";
  45. listC.textLabel.font=[UIFont systemFontOfSize:14];
  46. listC.textLabel.textColor=[UIColor colorWithHexString:fontColor];
  47. listC.detailTextLabel.text=model.phone;
  48. listC.detailTextLabel.font=[UIFont systemFontOfSize:14];
  49. listC.detailTextLabel.textColor=[UIColor colorWithHexString:@"#666666"];
  50. return listC;
  51. }
  52. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  53. {
  54. return 1;
  55. }
  56. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  57. {
  58. }
  59. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  60. {
  61. return 50;
  62. }
  63. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  64. {
  65. return 1;
  66. }
  67. -(UITableView *)setView
  68. {
  69. if (!_setView) {
  70. _setView=[[UITableView alloc]init];
  71. _setView.backgroundColor=[UIColor clearColor];
  72. _setView.separatorStyle=UITableViewCellSeparatorStyleNone;
  73. if (@available(iOS 11.0, *)) {
  74. _setView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  75. } else {
  76. self.automaticallyAdjustsScrollViewInsets = NO;
  77. }
  78. _setView.delegate=self;
  79. _setView.dataSource=self;
  80. }
  81. return _setView;
  82. }
  83. -(void)returnClickBtn
  84. {
  85. [self.navigationController popViewControllerAnimated:YES];
  86. }
  87. -(void)viewWillAppear:(BOOL)animated
  88. {
  89. [super viewWillAppear:animated];
  90. self.navigationController.navigationBar.hidden=YES;
  91. self.tabBarController.tabBar.hidden=YES;
  92. }
  93. -(void)viewWillDisappear:(BOOL)animated
  94. {
  95. [super viewWillDisappear:animated];
  96. self.tabBarController.tabBar.hidden=NO;
  97. }
  98. #pragma mark---退出登录
  99. -(void)exitClickButton
  100. {
  101. [KDPAccountTool deleteAccount];
  102. [self.navigationController popToRootViewControllerAnimated:YES];
  103. [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[[UINavigationController alloc]initWithRootViewController:[[KDPPhoneLoginViewController alloc]init]] animated:YES completion:^{
  104. KDPTabBarVC *tabbar = (KDPTabBarVC *)[UIApplication sharedApplication].keyWindow.rootViewController;
  105. tabbar.selectedIndex = 0;
  106. }];
  107. }
  108. - (UIViewController *)getCurrentVC {
  109. // Find best view controller
  110. UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
  111. return [self findBestViewController:viewController];
  112. }
  113. -(UIViewController*) findBestViewController:(UIViewController*)vc {
  114. if (vc.presentedViewController) {
  115. // Return presented view controller
  116. return [self findBestViewController:vc.presentedViewController];
  117. } else if ([vc isKindOfClass:[UISplitViewController class]]) {
  118. // Return right hand side
  119. UISplitViewController* svc = (UISplitViewController*) vc;
  120. if (svc.viewControllers.count > 0)
  121. return [self findBestViewController:svc.viewControllers.lastObject];
  122. else
  123. return vc;
  124. } else if ([vc isKindOfClass:[UINavigationController class]]) {
  125. // Return top view
  126. UINavigationController* svc = (UINavigationController*) vc;
  127. if (svc.viewControllers.count > 0)
  128. return [self findBestViewController:svc.topViewController];
  129. else
  130. return vc;
  131. } else if ([vc isKindOfClass:[UITabBarController class]]) {
  132. // Return visible view
  133. UITabBarController* svc = (UITabBarController*) vc;
  134. if (svc.viewControllers.count > 0)
  135. return [self findBestViewController:svc.selectedViewController];
  136. else
  137. return vc;
  138. } else {
  139. // Unknown view controller type, return last child view controller
  140. return vc;
  141. }
  142. }
  143. @end