123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- //
- // KDPSetViewController.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/9.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPSetViewController.h"
- #import "KDPPhoneLoginViewController.h"
- #import "KDPTabBarVC.h"
- @interface KDPSetViewController ()<UITableViewDelegate,UITableViewDataSource>
- {
-
- }
- @property(nonatomic,strong)UITableView *setView;
- @end
- @implementation KDPSetViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
- self.navBar.navTitleLabel.text=@"设置";
- self.view.backgroundColor=[UIColor colorWithHexString:LineColor];
- [self.view addSubview:self.setView];
-
- [self.setView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(KDNavBarHeight);
- make.left.right.mas_equalTo(0);
- make.bottom.mas_equalTo(self.view.mas_bottom).offset(-50);
- }];
-
- UIButton *exitButton=[[UIButton alloc]initWithFrame:CGRectMake(0, SCREEN_HEIGHT-50, SCREEN_WIDTH, 50)];
- [exitButton setTitleColor:[UIColor colorWithHexString:ThemeColor] forState:UIControlStateNormal];
- [exitButton setTitle:@"退出登录" forState:UIControlStateNormal];
- exitButton.titleLabel.font=[UIFont systemFontOfSize:14];
- [exitButton addTarget:self action:@selector(exitClickButton) forControlEvents:UIControlEventTouchUpInside];
- exitButton.backgroundColor=[UIColor whiteColor];
- [self.view addSubview:exitButton];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- UITableViewCell *listC=[tableView dequeueReusableCellWithIdentifier:@"set"];
- if (!listC) {
- listC=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"set"];
- listC.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- KDPAccountModel *model =[KDPAccountTool account];
- listC.textLabel.text=@"我的手机号";
- listC.textLabel.font=[UIFont systemFontOfSize:14];
- listC.textLabel.textColor=[UIColor colorWithHexString:fontColor];
-
- listC.detailTextLabel.text=model.phone;
- listC.detailTextLabel.font=[UIFont systemFontOfSize:14];
- listC.detailTextLabel.textColor=[UIColor colorWithHexString:@"#666666"];
-
-
-
- return listC;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return 1;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- return 50;
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- -(UITableView *)setView
- {
- if (!_setView) {
- _setView=[[UITableView alloc]init];
- _setView.backgroundColor=[UIColor clearColor];
- _setView.separatorStyle=UITableViewCellSeparatorStyleNone;
- if (@available(iOS 11.0, *)) {
- _setView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- _setView.delegate=self;
- _setView.dataSource=self;
-
- }
- return _setView;
- }
- -(void)returnClickBtn
- {
- [self.navigationController popViewControllerAnimated:YES];
- }
- -(void)viewWillAppear:(BOOL)animated
- {
- [super viewWillAppear:animated];
- self.navigationController.navigationBar.hidden=YES;
- self.tabBarController.tabBar.hidden=YES;
- }
- -(void)viewWillDisappear:(BOOL)animated
- {
- [super viewWillDisappear:animated];
- self.tabBarController.tabBar.hidden=NO;
- }
- #pragma mark---退出登录
- -(void)exitClickButton
- {
- [KDPAccountTool deleteAccount];
-
- [self.navigationController popToRootViewControllerAnimated:YES];
- [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:[[UINavigationController alloc]initWithRootViewController:[[KDPPhoneLoginViewController alloc]init]] animated:YES completion:^{
- KDPTabBarVC *tabbar = (KDPTabBarVC *)[UIApplication sharedApplication].keyWindow.rootViewController;
- tabbar.selectedIndex = 0;
- }];
- }
- - (UIViewController *)getCurrentVC {
- // Find best view controller
- UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController;
- return [self findBestViewController:viewController];
- }
- -(UIViewController*) findBestViewController:(UIViewController*)vc {
-
- if (vc.presentedViewController) {
-
- // Return presented view controller
- return [self findBestViewController:vc.presentedViewController];
-
- } else if ([vc isKindOfClass:[UISplitViewController class]]) {
-
- // Return right hand side
- UISplitViewController* svc = (UISplitViewController*) vc;
- if (svc.viewControllers.count > 0)
- return [self findBestViewController:svc.viewControllers.lastObject];
- else
- return vc;
-
- } else if ([vc isKindOfClass:[UINavigationController class]]) {
-
- // Return top view
- UINavigationController* svc = (UINavigationController*) vc;
- if (svc.viewControllers.count > 0)
- return [self findBestViewController:svc.topViewController];
- else
- return vc;
-
- } else if ([vc isKindOfClass:[UITabBarController class]]) {
-
- // Return visible view
- UITabBarController* svc = (UITabBarController*) vc;
- if (svc.viewControllers.count > 0)
- return [self findBestViewController:svc.selectedViewController];
- else
- return vc;
-
- } else {
-
- // Unknown view controller type, return last child view controller
- return vc;
-
- }
- }
- @end
|