新版本
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// IfishHotBarModifyNameVc.m
|
||||
// Ifish
|
||||
//
|
||||
// Created by 罗艺 on 2018/9/25.
|
||||
// Copyright © 2018年 lianlian. All rights reserved.
|
||||
//
|
||||
|
||||
#import "IfishHotBarModifyNameVc.h"
|
||||
|
||||
@interface IfishHotBarModifyNameVc ()
|
||||
@property (weak, nonatomic) IBOutlet UITextField *nameTextF;
|
||||
|
||||
@end
|
||||
|
||||
@implementation IfishHotBarModifyNameVc
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view from its nib.
|
||||
self.title=@"修改名称";
|
||||
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"保存" style:0 target:self action:@selector(clickModifyName)];
|
||||
UIImage *hamburger = [[UIImage imageNamed:@"back_btn"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
||||
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithImage:hamburger style:0 target:self action:@selector(clickBack)];
|
||||
}
|
||||
|
||||
-(void)clickBack{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"blackbar.png"] forBarMetrics:UIBarMetricsDefault];
|
||||
}
|
||||
|
||||
- (void)clickModifyName{
|
||||
[self modifyNameWith:self.nameTextF.text];
|
||||
}
|
||||
|
||||
|
||||
-(void)modifyNameWith:(NSString*)str{
|
||||
// priId.deviceId Integer 是 设备ID
|
||||
// priId.userId Integer 是 用户ID
|
||||
// showName string 是 显示名称
|
||||
|
||||
|
||||
NSDictionary*para=@{
|
||||
@"priId.deviceId":self.devicemodel.deviceId,
|
||||
@"priId.userId":self.devicemodel.userId,
|
||||
@"showName":str
|
||||
};
|
||||
[AFHttpTool requestWihtMethod:RequestMethodTypePost url:kUpdateDeviceUser params:para success:^(id response) {
|
||||
NSLog(@"-----------%@",response);
|
||||
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
|
||||
NSString*result=dict[@"result"];
|
||||
if ([result integerValue]==100) {
|
||||
// self.vo=[IfishHotBarVo mj_objectWithKeyValues:dict[@"data"]];
|
||||
[self.view makeToast:@"修改成功"];
|
||||
[[NSUserDefaults standardUserDefaults]setObject:str forKey:@"dTitle"];
|
||||
[self updateNameInLocalWithName:str];
|
||||
}
|
||||
} failure:^(NSError *err) {
|
||||
[self.view makeToast:@"修改失败"];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
-(void)updateNameInLocalWithName:(NSString*)name{
|
||||
NSArray* deviceArr =[dataContorl getallDevices];
|
||||
for (DeviceModel *device in deviceArr) {
|
||||
if (device.deviceId==self.devicemodel.deviceId) {
|
||||
device.showName=name;
|
||||
[[DataCenter defaultDtacenter]setValue:deviceArr forKey:@"deviceInfo"];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateDevice" object:nil];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user