123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- //
- // KDPUserInfoVC.m
- // KuDianProject
- //
- // Created by 学丽 on 2019/7/8.
- // Copyright © 2019 KDP. All rights reserved.
- //
- #import "KDPUserInfoVC.h"
- #import "KDPUserInfoListCell.h"
- @interface KDPUserInfoVC ()<UITableViewDelegate,UITableViewDataSource>
- {
- NSArray *infoArray;
- NSDictionary *userInfoDic;
- }
- @property(nonatomic,strong)UITableView *infoView;
- @end
- @implementation KDPUserInfoVC
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self addNavUI];
- [self getUserINfo];
-
- }
- -(void)getUserINfo
- {
- [LoadingView show];
- [KDPNetworkRequestHTTP postURL:UserInfoURL params:nil success:^(id _Nonnull json) {
- userInfoDic =json[@"data"];
- [self.infoView reloadData];
- [LoadingView dismiss];
- } failure:^(NSError * _Nonnull error) {
- [LoadingView dismiss];
- }];
- }
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- KDPUserInfoListCell *listC=[tableView dequeueReusableCellWithIdentifier:@"info"];
- if (!listC) {
- listC=[[KDPUserInfoListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"info"];
- listC.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- listC.nickLabel.text=infoArray[indexPath.row];
- if (indexPath.row == 0) {
- listC.iconImgV.hidden=NO;
- listC.contentLabel.hidden=YES;
- [listC.iconImgV sd_setImageWithURL:[NSURL URLWithString:userInfoDic[@"kwai_headurl"]]placeholderImage:[UIImage imageNamed:placholderImg]];
- }else{
- listC.contentLabel.hidden=NO;
- listC.iconImgV.hidden=YES;
- if (indexPath.row == 1) {
- NSString *userName = [userInfoDic[@"kwai_username"] isEqual:[NSNull null]] ? @"" : userInfoDic[@"kwai_username"];
- listC.contentLabel.text=userName;
- }else if (indexPath.row == 2) {
- listC.contentLabel.text=userInfoDic[@"kwai_num"];
- }else if (indexPath.row == 3) {
- NSInteger sex=[[NSString stringWithFormat:@"%@",userInfoDic[@"kwai_sex"]] integerValue];
- if (sex == 1) {
- listC.contentLabel.text=@"女";
- }else{
- listC.contentLabel.text=@"男";
- }
-
- }else if (indexPath.row == 4) {
- NSString *cityName = [userInfoDic[@"kwai_city_name"] isEqual:[NSNull null]] ? @"":userInfoDic[@"kwai_city_name"];
- listC.contentLabel.text=cityName;
- }else if (indexPath.row == 5) {
- listC.contentLabel.text=userInfoDic[@"favorite_cate"];
- }
-
- }
-
- return listC;
- }
- -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return infoArray.count;
- }
- -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
- {
-
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (indexPath.row == 0) {
- return 57;
- }
- return 43;
- }
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- {
- return 1;
- }
- -(UITableView *)infoView
- {
- if (!_infoView) {
- _infoView=[[UITableView alloc]init];
- _infoView.backgroundColor=[UIColor clearColor];
- _infoView.separatorStyle=UITableViewCellSeparatorStyleNone;
- if (@available(iOS 11.0, *)) {
- _infoView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
- } else {
- self.automaticallyAdjustsScrollViewInsets = NO;
- }
- _infoView.delegate=self;
- _infoView.dataSource=self;
-
- }
- return _infoView;
- }
- -(void)addNavUI
- {
- [self.navBar addleftReturnButton:self selector:@selector(returnClickBtn)];
- self.navBar.navTitleLabel.text=@"个人信息";
- infoArray =@[@"我的头像",@"我的昵称",@"快手号",@"性别",@"所在地",@"标签"];
- self.view.backgroundColor=[UIColor colorWithHexString:LineColor];
- [self.view addSubview:self.infoView];
- [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.mas_equalTo(0);
- make.top.mas_equalTo(KDNavBarHeight);
- }];
- }
- -(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;
- }
- @end
|