//
|
// Personal_informationViewController.m
|
// BuWanVideo2.0
|
//
|
// Created by apple on 16/10/12.
|
// Copyright © 2016年 com.yeshi.buwansheque.ios. All rights reserved.
|
//
|
|
#import "Personal_informationViewController.h"
|
#import "IconTableViewCell.h"
|
#import "InfoTableViewCell.h"
|
#import "signatureTableViewCell.h"
|
|
@interface Personal_informationViewController ()<UITableViewDelegate,UITableViewDataSource,UINavigationControllerDelegate,UIImagePickerControllerDelegate>{
|
UITableView *_tableView;
|
NSMutableArray *_dataArr;
|
|
BOOL _hasChanged; //是否含有修改
|
UIImage *_newiconImage; //自己截取,并且还未上传的头像
|
|
//以下属性是从网络获取的数据,如果为nil,说明没有数据,加载默认属性就可以了
|
NSString *_portrait;//头像的URL
|
NSString *_Nickname;//昵称
|
NSString *_Sex;//性别
|
NSString *_BirthDay;//出生日期
|
NSString *_Sign;//个性签名
|
|
//当用户修改用户名时,用于存储临时变量,为什么不直接在_Nickname上修改呐?--为的是防止用户点取消保存的按钮!!!
|
NSString *_tempNickname;
|
NSString *_tempSign;
|
//装载时间选择器的视图
|
UIView *_dateView;
|
//装载时间选选择器背后的半透明背景
|
UIView *datePickerView;
|
//时间选择器
|
UIDatePicker *datePicker;
|
}
|
|
@end
|
|
@implementation Personal_informationViewController
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
[self loadData];
|
}
|
-(void)loadData{
|
self.navigationItem.title = @"个人资料";
|
self.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor blackColor]};
|
//返回按钮
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
[button setImage:[[UIImage imageNamed:@"详情页面返回"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
|
[button addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
|
button.frame = CGRectMake(0, 0, 32, 32);
|
UIBarButtonItem *iconBarItem=[[UIBarButtonItem alloc] initWithCustomView:button];
|
self.navigationItem.leftBarButtonItem = iconBarItem;
|
|
//保存按钮
|
UIButton *saveButton=[UIButton buttonWithType:UIButtonTypeCustom];
|
[saveButton setTitle:@"保存" forState:UIControlStateNormal];
|
[saveButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
[saveButton setTitleColor:[UIColor grayColor] forState:UIControlStateSelected];
|
[saveButton addTarget:self action:@selector(SaveInfo) forControlEvents:UIControlEventTouchUpInside];
|
saveButton.frame=CGRectMake(0, 0, 44, 32);
|
UIBarButtonItem *saveBarItem=[[UIBarButtonItem alloc] initWithCustomView:saveButton];
|
self.navigationItem.rightBarButtonItem=saveBarItem;
|
|
//列表
|
_dataArr = [[NSMutableArray alloc] initWithObjects:@[@"修改头像"],@[@"昵称",@"生日",@"性别"],@[@"个性签名"], nil];
|
|
if(_tableView==nil){
|
_tableView=[[UITableView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH) style:UITableViewStyleGrouped];
|
_tableView.delegate=self;
|
_tableView.dataSource=self;
|
[self.view addSubview:_tableView];
|
_tableView.backgroundColor=kGlobalBackgroundColor;
|
}
|
[_tableView registerNib:[UINib nibWithNibName:@"IconTableViewCell" bundle:nil] forCellReuseIdentifier:@"IconTableViewCell"];
|
[_tableView registerNib:[UINib nibWithNibName:@"InfoTableViewCell" bundle:nil] forCellReuseIdentifier:@"InfoTableViewCell"];
|
[_tableView registerNib:[UINib nibWithNibName:@"signatureTableViewCell" bundle:nil] forCellReuseIdentifier:@"signatureTableViewCell"];
|
|
//从网络获取数据
|
[self getInfoFromInternet];
|
}
|
|
/**
|
从网络获取数据
|
*/
|
-(void)getInfoFromInternet{
|
[[YTHNetInterface startInterface] getLoginUserInfoWithUid:[YTHsharedManger startManger].Uid WithSystem:@"1" WithLoginUid:[[NSUserDefaults standardUserDefaults] objectForKey:@"LoginUid"] withBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if (isSuccessful) {
|
//首先判断数据是否获成功
|
NSString *err=[NSString stringWithFormat:@"%@",[result objectForKey:@"Error"]];
|
if (err.length==0) {
|
if ([[result objectForKey:@"Data"] objectForKey:@"Portrait"]!=nil) {
|
NSString *str=[[result objectForKey:@"Data"] objectForKey:@"Portrait"];
|
NSLog(@"%@",str);
|
if ([[str substringWithRange:NSMakeRange(0, 4)] isEqualToString:@"http"]) {
|
_portrait=str;
|
}else{
|
_portrait=[NSString stringWithFormat:@"%@%@",iconImageUrl,str];
|
}
|
}
|
if ([[result objectForKey:@"Data"] objectForKey:@"Nickname"]!=nil) {
|
_Nickname=[[result objectForKey:@"Data"] objectForKey:@"Nickname"];
|
}
|
if ([[result objectForKey:@"Data"] objectForKey:@"Sex"]!=nil) {
|
_Sex=[[result objectForKey:@"Data"] objectForKey:@"Sex"];
|
}
|
if ([[result objectForKey:@"Data"] objectForKey:@"Birthday"]!=nil) {
|
_BirthDay=[[result objectForKey:@"Data"] objectForKey:@"Birthday"];
|
}
|
if ([[result objectForKey:@"Data"] objectForKey:@"Sign"]!=nil) {
|
_Sign=[[result objectForKey:@"Data"] objectForKey:@"Sign"];
|
}
|
//刷新列表数据
|
[_tableView reloadData];
|
}else{
|
NSLog(@"%@",err);
|
}
|
}else{
|
//提示用户网络连接失败,并提供
|
if ([error compare:@"似乎已断开与互联网的连接。"] == 0) {
|
[self autoDisappearAlertTime:1 msg:@"网络不可用,请检查网络"];
|
}
|
}
|
}];
|
}
|
|
|
/**
|
上传更改的信息
|
*/
|
-(void)SaveInfo{
|
//判断是否有修改,如果没有修改就没有必要上传信息了
|
if(_hasChanged){
|
//要判断用户是否修改了头像,如果用户没有修改头像,就不需要同步头像
|
NSString *iconStr;
|
if(_newiconImage!=nil){
|
//头像编码
|
iconStr=[self imageTransFormBase64:_newiconImage];
|
}
|
[SVProgressHUD showWithStatus:@"保存中..."];
|
[[YTHNetInterface startInterface] getupdateLoginUserInfoWithUid:[YTHsharedManger startManger].Uid WithSystem:@"1" WithLoginUid:[[NSUserDefaults standardUserDefaults] objectForKey:@"LoginUid"] WithSex:_Sex WithBirthDay:_BirthDay WithPersonalSign:_Sign WithNickName:_Nickname WithPortrait:_newiconImage==nil?nil:iconStr withBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if (isSuccessful) {
|
//请求成功
|
NSString *err=[NSString stringWithFormat:@"%@",[result objectForKey:@"Error"]];
|
if (err.length==0) {
|
//重新存储新的昵称
|
[[NSUserDefaults standardUserDefaults] setObject:_Nickname forKey:@"QQUserName"];
|
[[YTHNetInterface startInterface] getLoginUserInfoWithUid:[YTHsharedManger startManger].Uid WithSystem:@"1" WithLoginUid:[[NSUserDefaults standardUserDefaults] objectForKey:@"LoginUid"] withBlock:^(BOOL isSuccessful, id result, NSString *error) {
|
if (isSuccessful) {
|
//首先判断数据是否获成功
|
NSString *err=[NSString stringWithFormat:@"%@",[result objectForKey:@"Error"]];
|
if (err.length==0) {
|
//上传成功
|
_hasChanged=NO;
|
//跟新个人信息到全局变量
|
if ([[result objectForKey:@"Data"] objectForKey:@"Portrait"]!=nil) {
|
NSString *str=[[result objectForKey:@"Data"] objectForKey:@"Portrait"];
|
if ([[str substringWithRange:NSMakeRange(0, 4)] isEqualToString:@"http"]) {
|
_portrait=str;
|
}else{
|
_portrait=[NSString stringWithFormat:@"%@%@",iconImageUrl,str];
|
}
|
[[NSUserDefaults standardUserDefaults] setObject:_portrait forKey:@"iconURL"];
|
}
|
if ([[result objectForKey:@"Data"] objectForKey:@"Nickname"]!=nil) {
|
[[NSUserDefaults standardUserDefaults] setObject:_Nickname forKey:@"QQUserName"];
|
}
|
//通知刷新视图
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"RELOAD_DATA" object:nil];
|
//显示保存成功
|
[SVProgressHUD showSuccessWithStatus:@"保存成功!"];
|
}else{
|
//错误原因
|
[SVProgressHUD dismiss];
|
NSLog(@"%@",err);
|
}
|
}else{
|
//提示用户网络连接失败,并提供
|
[SVProgressHUD showErrorWithStatus:@"保存失败!"];
|
}
|
}];
|
}else{
|
//上传失败
|
[SVProgressHUD dismiss];
|
NSLog(@"%@",err);
|
}
|
}else{
|
[SVProgressHUD dismiss];
|
//请求失败,网络问题
|
}
|
}];
|
}
|
}
|
|
/**
|
返回
|
|
@param sender 返回按钮
|
*/
|
-(void)back:(id)sender{
|
if (_hasChanged) {
|
//当前信息有修改,但是并未保存
|
UIAlertController *Alert=[UIAlertController alertControllerWithTitle:@"当前信息未保存" message:@"是否保存修改信息" preferredStyle:UIAlertControllerStyleAlert];
|
//取消按钮
|
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
//退出当前界面
|
_hasChanged=NO;
|
[self.navigationController popViewControllerAnimated:YES];
|
}];
|
[Alert addAction:cancel];
|
//保存按钮
|
UIAlertAction *certain = [UIAlertAction actionWithTitle:@"保存" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
[self SaveInfo];
|
}];
|
[Alert addAction:certain];
|
[self presentViewController:Alert animated:YES completion:nil];
|
}else{
|
[self.navigationController popViewControllerAnimated:YES];
|
}
|
}
|
|
|
/**
|
隐藏时间选择器视图
|
|
@param sender 按钮
|
*/
|
-(void)HiddenDateView:(UIButton *)sender{
|
[datePickerView removeFromSuperview];
|
[_dateView removeFromSuperview];
|
}
|
|
|
/**
|
保存设置的日期,并移除时间选择器视图
|
|
@param sender 按钮
|
*/
|
-(void)SaveDateView:(UIButton *)sender{
|
NSDateFormatter* df = [[NSDateFormatter alloc]init];
|
[df setDateFormat:@"yyyy-MM-dd"];
|
_BirthDay = [df stringFromDate:datePicker.date];
|
_hasChanged=YES;
|
[_tableView reloadData];
|
[datePickerView removeFromSuperview];
|
[_dateView removeFromSuperview];
|
}
|
|
|
|
#pragma mark - UITableViewDelegate
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
if(indexPath.section==0){//修改头像
|
/**
|
* 弹出提示框
|
*/
|
//初始化提示框
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
[alert addAction:[UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
UIImagePickerController *PickerImage = [[UIImagePickerController alloc]init];
|
//获取方式1:通过相册(呈现全部相册),UIImagePickerControllerSourceTypePhotoLibrary
|
//获取方式2,通过相机,UIImagePickerControllerSourceTypeCamera
|
//获取方法3,通过相册(呈现全部图片),UIImagePickerControllerSourceTypeSavedPhotosAlbum
|
PickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
|
//允许编辑,即放大裁剪
|
PickerImage.allowsEditing = YES;
|
//自代理
|
PickerImage.delegate = self;
|
//页面跳转
|
[self presentViewController:PickerImage animated:YES completion:nil];
|
}]];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
UIImagePickerController *PickerImage = [[UIImagePickerController alloc]init];
|
//获取方式:通过相机
|
PickerImage.sourceType = UIImagePickerControllerSourceTypeCamera;
|
PickerImage.allowsEditing = YES;
|
PickerImage.delegate = self;
|
[PickerImage.navigationController.navigationBar setBackgroundColor:kGlobalMainColor];
|
[self presentViewController:PickerImage animated:YES completion:nil];
|
}]];
|
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil]];
|
[self presentViewController:alert animated:YES completion:nil];
|
|
}else if (indexPath.section==1){
|
if (indexPath.row==0) {//昵称
|
UIAlertController *modifyNicknameAlert=[UIAlertController alertControllerWithTitle:@"修改昵称" message:@"昵称需要大于2个字符!" preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
//这里面写取消修改昵称的操作
|
}];
|
[modifyNicknameAlert addAction:cancel];
|
UIAlertAction *certain = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
if (_tempNickname.length>1) {
|
_Nickname=_tempNickname;
|
_hasChanged=YES;
|
[_tableView reloadData];
|
}
|
}];
|
[modifyNicknameAlert addAction:certain];
|
|
[modifyNicknameAlert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
|
// 监听
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleTextFieldTextDidChangeNotification:) name:UITextFieldTextDidChangeNotification object:textField];
|
// 定制键盘和输入框背景文字及clearButton
|
textField.placeholder = [NSString stringWithFormat:@"%@",_Nickname];
|
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
textField.autocorrectionType=UITextAutocorrectionTypeNo;
|
}];
|
[self presentViewController:modifyNicknameAlert animated:YES completion:nil];
|
}else if(indexPath.row==1){//生日
|
datePicker=[[UIDatePicker alloc] initWithFrame:CGRectMake(0, 44, KScreenW, 216)];
|
datePicker.backgroundColor=[UIColor whiteColor];
|
//配置语言
|
NSLocale *locale=[[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];
|
datePicker.locale=locale;
|
//配置类型
|
datePicker.datePickerMode=UIDatePickerModeDate;
|
//配置时间范围
|
NSDate *maxDate = [[NSDate alloc]initWithTimeIntervalSince1970:0];
|
datePicker.maximumDate = maxDate;
|
NSDate *minDate = [NSDate date];
|
datePicker.maximumDate = minDate;
|
//设置输出的格式
|
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
|
//设置初始时间
|
NSDate* inputDate;
|
if(_BirthDay!=nil){
|
inputDate = [dateFormatter dateFromString:_BirthDay];
|
}else{
|
inputDate = [dateFormatter dateFromString:@"1990-01-01"];
|
}
|
[datePicker setDate:inputDate animated:YES];
|
|
|
//将时间选择器放在一个视图上
|
_dateView=[[UIView alloc] initWithFrame:CGRectMake(0, KScreenH-260, KScreenW, 260)];
|
_dateView.backgroundColor=KGlobalLightGreyColor_255;
|
//时间选择器的取消按钮
|
UIButton *DatePickerCancelBtn=[[UIButton alloc] initWithFrame:CGRectMake(13, 7, 52, 30)];
|
[DatePickerCancelBtn setTitle:@"取消" forState:UIControlStateNormal];
|
[DatePickerCancelBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
[DatePickerCancelBtn addTarget:self action:@selector(HiddenDateView:) forControlEvents:UIControlEventTouchUpInside];
|
//时间选择器的确认按钮
|
UIButton *DatePickerSureBtn=[[UIButton alloc] initWithFrame:CGRectMake(KScreenW-65, 7, 52, 30)];
|
[DatePickerSureBtn setTitle:@"确定" forState:UIControlStateNormal];
|
[DatePickerSureBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
[DatePickerSureBtn addTarget:self action:@selector(SaveDateView:) forControlEvents:UIControlEventTouchUpInside];
|
//添加
|
[_dateView addSubview:datePicker];
|
[_dateView addSubview:DatePickerCancelBtn];
|
[_dateView addSubview:DatePickerSureBtn];
|
|
//添加一层半透明的背景
|
datePickerView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenW, KScreenH)];
|
datePickerView.backgroundColor=KGlobalLightGreyColor_153;
|
[self.view addSubview:datePickerView];
|
[self.view addSubview:_dateView];
|
}else{//性别
|
UIAlertController *modifySexnameAlert=[UIAlertController alertControllerWithTitle:@"请选择你的性别" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
|
UIAlertAction *man=[UIAlertAction actionWithTitle:@"男" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
_Sex=@"1";
|
_hasChanged=YES;
|
[_tableView reloadData];
|
[modifySexnameAlert dismissViewControllerAnimated:YES completion:nil];
|
}];
|
[modifySexnameAlert addAction:man];
|
|
UIAlertAction *woman=[UIAlertAction actionWithTitle:@"女" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
_Sex=@"0";
|
_hasChanged=YES;
|
[_tableView reloadData];
|
[modifySexnameAlert dismissViewControllerAnimated:YES completion:nil];
|
}];
|
[modifySexnameAlert addAction:woman];
|
|
UIAlertAction *cancel=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
|
}];
|
[modifySexnameAlert addAction:cancel];
|
|
[self presentViewController:modifySexnameAlert animated:YES completion:^{
|
|
}];
|
}
|
}else{//个性签名
|
UIAlertController *modifySignAlert=[UIAlertController alertControllerWithTitle:@"修改个性签名" message:nil preferredStyle:UIAlertControllerStyleAlert];
|
|
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
|
//这里面写取消修改昵称的操作
|
}];
|
[modifySignAlert addAction:cancel];
|
UIAlertAction *certain = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
if (_tempSign.length>0) {
|
_Sign=_tempSign;
|
_hasChanged=YES;
|
[_tableView reloadData];
|
}
|
}];
|
[modifySignAlert addAction:certain];
|
|
[modifySignAlert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
|
// 监听
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(SignTextFieldTextDidChangeNotification:) name:UITextFieldTextDidChangeNotification object:textField];
|
// 定制键盘和输入框背景文字及clearButton
|
if (_Sign!=nil) {
|
textField.placeholder = [NSString stringWithFormat:@"%@",_Sign];
|
textField.text=_Sign;
|
textField.autocorrectionType=UITextAutocorrectionTypeNo;
|
}else{
|
textField.placeholder =@"写出你的个性吧!";
|
}
|
|
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
}];
|
[self presentViewController:modifySignAlert animated:YES completion:nil];
|
}
|
}
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
if (indexPath.section==0) {
|
return 65;
|
}else if(indexPath.section==1){
|
return 50;
|
}else{
|
return 60;
|
}
|
}
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
if (section==0) {
|
return 22;
|
}else{
|
return 11;
|
}
|
}
|
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
return 0;
|
}
|
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
|
return [NSString stringWithFormat:@""];
|
}
|
|
#pragma mark - UITableViewDataSource
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
return [_dataArr[section] count];
|
}
|
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
return 3;
|
}
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
if (indexPath.section==0) {
|
IconTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"IconTableViewCell"];
|
cell.cellTitle.text=_dataArr[indexPath.section][indexPath.row];
|
if (_newiconImage!=nil) {
|
[cell.iconImageView setImage:_newiconImage];
|
}else if (_portrait!=nil) {
|
[cell.iconImageView setYthImageWithURL:_portrait placeholderImage:[UIImage imageNamed:@"关注默认头像"]];
|
}else{
|
cell.iconImageView.image=[UIImage imageNamed:@"关注默认头像"];
|
}
|
cell.backgroundColor=[UIColor whiteColor];
|
return cell;
|
}else if(indexPath.section==1){
|
InfoTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"InfoTableViewCell"];
|
cell.cellTitle.text=_dataArr[indexPath.section][indexPath.row];
|
if (indexPath.row==0) {
|
if (_Nickname!=nil) {
|
cell.cellInfo.text=_Nickname;
|
}else{
|
cell.cellInfo.text=@"布丸用户";
|
}
|
}else if (indexPath.row==1){
|
if (_BirthDay!=nil) {
|
cell.cellInfo.text=_BirthDay;
|
}else{
|
cell.cellInfo.text=@"1990-01-01";
|
}
|
}else{
|
if (_Sex!=nil) {
|
if ([_Sex isEqualToString:@"0"]) {
|
cell.cellInfo.text=@"女";
|
}else if ([_Sex isEqualToString:@"1"]){
|
cell.cellInfo.text=@"男";
|
}
|
}else{
|
cell.cellInfo.text=@"未知";
|
}
|
}
|
cell.cellInfo.textColor= [UIColor blackColor];
|
cell.backgroundColor=[UIColor whiteColor];
|
return cell;
|
}else{
|
signatureTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"signatureTableViewCell"];
|
cell.cellTitle.text=_dataArr[indexPath.section][indexPath.row];
|
if (_Sign!=nil) {
|
cell.cellInfo.text=_Sign;
|
}
|
cell.backgroundColor=[UIColor whiteColor];
|
return cell;
|
}
|
}
|
|
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
[datePickerView removeFromSuperview];
|
[_dateView removeFromSuperview];
|
}
|
|
#pragma mark -UIImagePickerControllerDelegate
|
//PickerImage完成后的代理方法
|
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info{
|
//定义一个newPhoto,用来存放我们选择的图片。
|
UIImage *newPhoto = [info objectForKey:@"UIImagePickerControllerEditedImage"];
|
_newiconImage= newPhoto;
|
[_tableView reloadData];
|
_hasChanged=YES;
|
[self dismissViewControllerAnimated:YES completion:nil];
|
}
|
#pragma mark 监听事件
|
//昵称的监听
|
- (void)handleTextFieldTextDidChangeNotification:(NSNotification *)notification{
|
UITextField *textField = notification.object;
|
_tempNickname = textField.text;
|
}
|
//个性签名的监听
|
- (void)SignTextFieldTextDidChangeNotification:(NSNotification *)notification{
|
UITextField *textField = notification.object;
|
_tempSign = textField.text;
|
}
|
|
#pragma mark 图片编码
|
- (NSString *) imageTransFormBase64: (UIImage *) image{
|
NSData *imageData = nil;
|
imageData = UIImageJPEGRepresentation(image, 0.5);
|
return [NSString stringWithFormat:@"%@",
|
[imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]];
|
}
|
|
@end
|