// // 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 () { } @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