// // GiGaUserViewController.m // GIGA // // Created by lianxiang on 2018/8/13. // Copyright © 2018年 com.giga.ios. All rights reserved. // #import "GiGaUserViewController.h" #import "GIGaUserInfoAvatorCell.h" #import "GIGaUserIDViewCell.h" #import "GIGaUserWeChatViewCell.h" #import "GiGaUserSexViewCell.h" #import "GIGaUserCityViewCell.h" @interface GiGaUserViewController () @end @implementation GiGaUserViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. //self.title = @"个人中心"; [self addNavTitile:@"个人信息"]; UIButton *saveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [saveBtn addTarget:self action:@selector(saveUserInfo) forControlEvents:UIControlEventTouchUpInside]; saveBtn.frame = CGRectMake(0, 0,40, 36); NSAttributedString *attrititle = [GiGaHelper stringWithText:@"保存" textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTMEDIUM(16) leterSpace:0]; [saveBtn setAttributedTitle:attrititle forState:UIControlStateNormal]; UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithCustomView:saveBtn]; self.navigationItem.rightBarButtonItem = saveItem; [self creatTab]; } -(void)creatTab{ [self.view addSubview:self.tableView]; self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.backgroundColor = [UIColor whiteColor]; self.tableView.separatorStyle = UITableViewCellSelectionStyleNone; self.tableView.sectionFooterHeight = 0; self.tableView.estimatedSectionFooterHeight= 0; self.tableView.estimatedSectionHeaderHeight = 0; self.tableView.bounces = NO; self.tableView.frame = CGRectMake(0,PhoneX_TopMargin + 1, KMainW,KMainH - PhoneX_BottomMargin); } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 3; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ if (section == 0){ return 1; }else if (section == 1){ return 3; } return 4; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.section ==0){ GIGaUserInfoAvatorCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserInfoAvatorCell"]; if(!cell){ cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserInfoAvatorCell" owner:self options:nil] lastObject]; } return cell; }else if (indexPath.section == 1 && indexPath.row < 2){ GIGaUserIDViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserIDViewCell"]; if(!cell){ cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserIDViewCell" owner:self options:nil] lastObject]; } return cell; }else if (indexPath.section == 1 && indexPath.row == 2){ GIGaUserWeChatViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserWeChatViewCell"]; if(!cell){ cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserWeChatViewCell" owner:self options:nil] lastObject]; } return cell; }else if (indexPath.section == 2 && indexPath.row == 0){ GiGaUserSexViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaUserSexViewCell"]; if(!cell){ cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaUserSexViewCell" owner:self options:nil] lastObject]; } return cell; }else if (indexPath.section == 2 && indexPath.row >= 1){ GIGaUserCityViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GIGaUserCityViewCell"]; if(!cell){ cell = [[[NSBundle mainBundle] loadNibNamed:@"GIGaUserCityViewCell" owner:self options:nil] lastObject]; } return cell; } return nil; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ if(indexPath.section==0){ return 133; }else { return 44; } } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.1; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (section == 1){ return 10; }else if (section == 2){ return 4; } return 0.1; } -(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ if (section == 1 || section == 2) { UIView *view = [[UIView alloc] init]; view.backgroundColor = GIGARGB(222, 222, 222, 1); return view; } return nil; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - 保存用户信息 -(void)saveUserInfo{ } @end