// // IfishSetViewController.m // Ifish // // Created by imac on 2017/4/19. // Copyright © 2017年 lianlian. All rights reserved. // #import "IfishSetViewController.h" #import "leftCell.h" #import "LeftCellmodel.h" #import "ChangeMobleController.h" #import "ChangeSecretCodeController.h" #define TUICHUAlertTAg 4100 #import "IfishUserDefaultHelper.h" #import "RestartViewController.h" #import "SettingResetViewController.h" @interface IfishSetViewController () @property(nonatomic,strong)UITableView *tableView; @property (nonatomic,strong) NSArray *imgs; @property (nonatomic,strong) NSArray *titles; @end extern BOOL firstLogIn; @implementation IfishSetViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self addTitleViewWithTitle:@"设置"]; [self loadData]; [self creatTab]; } -(void)loadData{ self.titles=@[@[@"更换手机",@"修改密码",@"设备重启",@"恢复出厂模式"],@[@"切换账号"]]; self.imgs = @[@[@"personal_iocn_replace",@"replace_iocn_code",@"setting-restart",@"setting-reset"],@[@"personal_iocn_switch"]]; } -(void)creatTab{ UITableView*table=[[UITableView alloc]initWithFrame:CGRectMake(0,0,self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStyleGrouped]; table.dataSource=self; table.delegate=self; table.separatorStyle=UITableViewCellSeparatorStyleNone; self.tableView=table; self.tableView.showsVerticalScrollIndicator=NO; self.tableView.backgroundColor = TABLE_HEADER_COLOR; [self.view addSubview:self.tableView]; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return 60.0; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [self.titles[section] count]; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return self.titles.count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ leftCell*cell=[tableView dequeueReusableCellWithIdentifier:@"leftCell"]; if (cell==nil) { cell= [[[NSBundle mainBundle]loadNibNamed:@"leftCell" owner:self options:nil]lastObject]; } cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; LeftCellmodel*lModel=[[LeftCellmodel alloc]init]; lModel.headig=self.imgs[indexPath.section][indexPath.row]; lModel.funTitle=self.titles[indexPath.section][indexPath.row]; [cell.headimag setImage:[UIImage imageNamed:lModel.headig]]; cell.titleLabel.text=lModel.funTitle; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.1f; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 10.0f; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (indexPath.section==0&&indexPath.row==0) { self.hidesBottomBarWhenPushed = YES; ChangeMobleController*changeVC=[[ChangeMobleController alloc]init]; [self.navigationController pushViewController:changeVC animated:YES]; }else if (indexPath.section==0&&indexPath.row==1){ self.hidesBottomBarWhenPushed = YES; ChangeSecretCodeController *secretVC=[[ChangeSecretCodeController alloc]init]; [self.navigationController pushViewController:secretVC animated:YES]; } else if (indexPath.section == 0 && indexPath.row == 2) { self.hidesBottomBarWhenPushed = YES; RestartViewController *vc = [[RestartViewController alloc] initWithNibName:@"RestartViewController" bundle:nil]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } else if (indexPath.section == 0 && indexPath.row == 3) { self.hidesBottomBarWhenPushed = YES; SettingResetViewController *vc = [[SettingResetViewController alloc] initWithNibName:@"SettingResetViewController" bundle:nil]; vc.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:vc animated:YES]; } else if (indexPath.section==1&&indexPath.row==0){ UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@"提醒" message:@"确认切换账号并重新登录?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; alert.tag=TUICHUAlertTAg; [alert show]; } } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ switch (alertView.tag) { case TUICHUAlertTAg: { if (buttonIndex==1) { firstLogIn = NO; [[Socketsingleton sharedInstance] cutOffSocket]; //切换 时重置标志位 [IfishUserDefaultHelper clearUserWhenUserChange]; //首次广告 [IfishUserDefaultHelper showAdview:NO]; //云信推出登陆 [[[NIMSDK sharedSDK] loginManager] logout:^(NSError *error) { // extern NSString *NTESNotificationLogout; // [[NSNotificationCenter defaultCenter] postNotificationName:NTESNotificationLogout object:nil]; }]; LogInViewController*logIn=[[LogInViewController alloc]init]; UINavigationController*nav=[[UINavigationController alloc]initWithRootViewController:logIn]; [nav.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault]; [UIApplication sharedApplication].delegate.window.rootViewController = nav; } } break; default: break; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end