完成设备修改页面

This commit is contained in:
xuemh
2018-04-23 01:00:35 +08:00
parent df311d475c
commit 68d441eb0d
4 changed files with 179 additions and 6 deletions
@@ -0,0 +1,13 @@
//
// RuiMeiInputViewController.h
// Ifish
//
// Created by Minghao Xue on 2018/4/23.
// Copyright © 2018年 lianlian. All rights reserved.
//
#import "IfishDeviceControlNameBaseController.h"
@interface RuiMeiInputViewController : IfishDeviceControlNameBaseController
@end
@@ -0,0 +1,157 @@
//
// RuiMeiInputViewController.m
// Ifish
//
// Created by Minghao Xue on 2018/4/23.
// Copyright © 2018年 lianlian. All rights reserved.
//
#import "RuiMeiInputViewController.h"
#import "RuSunChangeNameTextViewCell.h"
#define RUSUNCHCELL_CH1 20000
#define RUSUNCHCELL_CH2 20001
#define RUSUNCHCELL_CH3 20002
#define RUSUNCHCELL_CH4 20003
#define RUSUNCHCELL_JIARE 20004
#import "RuiMeiCHNameCustom.h"
#import "RuiMeiCHControl.h"
#import "UserExtendataArchaver.h"
@interface RuiMeiInputViewController ()
@end
@implementation RuiMeiInputViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource =self;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (section==0) {
return 1;
}else{
return 5;
}
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.section==0) {
return [super baseViewLoadDeviceNameCell:indexPath intable:tableView];
}
RuSunChangeNameTextViewCell*cell=[tableView dequeueReusableCellWithIdentifier:@"RuSunChangeNameTextViewCell"];
if (cell==nil) {
cell= [[[NSBundle mainBundle]loadNibNamed:@"RuSunChangeNameTextViewCell" owner:self options:nil]lastObject];
}
//控制原名
if (indexPath.row==4&&indexPath.section==1) {
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
}
NSArray *titles= @[@"S1",@"S2",@"UV/杀菌",@"冲浪/氧泵",@"加热棒"];
if (indexPath.section==1) {
cell.chTitle.text = titles[indexPath.row];
}
//自定义名字
RuiMeiCHControl * ruSunch = [RuiMeiCHNameCustom currentdevice:self.device.macAddress];
if (indexPath.section==1&&indexPath.row==0) {
cell.chName.text = ruSunch.ch1name;
}else if (indexPath.section==1&&indexPath.row==1){
cell.chName.text = ruSunch.ch2name;
}else if (indexPath.section==1&&indexPath.row==2){
cell.chName.text = ruSunch.ch3name;
}else if (indexPath.section==1&&indexPath.row==3){
cell.chName.text = ruSunch.ch4name;
}else if (indexPath.section==1&&indexPath.row==4){
cell.chName.text = ruSunch.jiaRe;
}
cell.chName.delegate = self;
cell.tag = 20000 + indexPath.row;
return cell;
}
-(void)sureAction
{
//RuiMeiCHNameCustom 本地处理 保存按钮名称 不与服务器交互
RuiMeiCHControl *ruSunch = [[RuiMeiCHControl alloc] init];
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:RUSUNCHCELL_CH1];
if (cell1.chName.text.length>3) {
[self.view makeToast:@"S1不能超过3个字"];
return;
}
if (cell1.chName.text.length==0) {
[self.view makeToast:@"S1不能为空"];
return;
}
ruSunch.ch1name = cell1.chName.text;
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:RUSUNCHCELL_CH2];
if (cell2.chName.text.length>3) {
[self.view makeToast:@"S2不能超过3个字"];
return;
}
if (cell2.chName.text.length==0) {
[self.view makeToast:@"S2不能为空"];
return;
}
ruSunch.ch2name = cell2.chName.text;
RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:RUSUNCHCELL_CH3];
if (cell3.chName.text.length>3) {
[self.view makeToast:@"UV/杀菌不能超过3个字"];
return;
}
if (cell3.chName.text.length==0) {
[self.view makeToast:@"UV/杀菌不能为空"];
return;
}
ruSunch.ch3name = cell3.chName.text;
RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:RUSUNCHCELL_CH4];
if (cell4.chName.text.length>3) {
[self.view makeToast:@"冲浪/氧泵不能超过3个字"];
return;
}
if (cell4.chName.text.length==0) {
[self.view makeToast:@"冲浪/氧泵不能为空"];
return;
}
ruSunch.ch4name = cell4.chName.text;
RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:RUSUNCHCELL_JIARE];
if (cell5.chName.text.length>3) {
[self.view makeToast:@"加热棒名不能超过3个字"];
return;
}
if (cell5.chName.text.length==0) {
[self.view makeToast:@"加热棒名不能为空"];
return;
}
ruSunch.jiaRe = cell5.chName.text;
ruSunch.macAd = self.device.macAddress;
[RuiMeiCHNameCustom saveCHname:ruSunch];
[self upLoadDeviceName];
}
@end
@@ -21,11 +21,10 @@
#import "XuToWenDuPicview.h"
#import "RuSunLightOrder.h"
#import "RuSunGuiDeng.h"
#import "RunSun84CHSetViewController.h"
#import "RuiMeiSetViewController.h"
#import "RuiMeiCHControl.h"
#import "RuiMeiCHNameCustom.h"
#import "RuSunInpdViewController.h"
#import "RuiMeiInputViewController.h"
#import "HaveHotCoolWenDuPicview.h"
@interface RuiMeiViewController ()<IfishCommuniteDelegate>
@@ -36,7 +35,7 @@
@property(nonatomic,strong) HaveHotCoolWenDuPicview *wenduPicview;
@property(nonatomic,strong) RuiMeiSetViewController *setVC;
//@property(nonatomic,strong) RunSunChangeNameViewController *changenameVC;
@property(nonatomic,strong) RuSunInpdViewController *changenameVC;
@property(nonatomic,strong) RuiMeiInputViewController *changenameVC;
@end
@@ -559,9 +558,7 @@
-(void)shezhiMingCheng
{
//_changenameVC = [[RunSunChangeNameViewController alloc] init];
_changenameVC = [[RuSunInpdViewController alloc] init];
_changenameVC = [[RuiMeiInputViewController alloc] init];
_changenameVC.name = self.name.text;
_changenameVC.device = self.currentDevice;
__weak typeof (self)wself = self;