// // 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