196 lines
5.5 KiB
Objective-C
196 lines
5.5 KiB
Objective-C
//
|
|
// RuSunInpdViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 2017/6/13.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "RuSunInpdViewController.h"
|
|
//#import "RuSunChangeNameTitleViewCell.h"
|
|
#import "RuSunChangeNameTextViewCell.h"
|
|
//#define RUSUN_DEVICENAME 100001
|
|
#define RUSUNCHCELL_CH1 20000
|
|
#define RUSUNCHCELL_CH2 20001
|
|
#define RUSUNCHCELL_CH3 20002
|
|
#define RUSUNCHCELL_CH4 20003
|
|
#define RUSUNCHCELL_GUIDENG 20004
|
|
#define RUSUNCHCELL_JIARE 20005
|
|
#import "RunSunCHNameCustom.h"
|
|
#import "RunSunCHControl.h"
|
|
#import "UserExtendataArchaver.h"
|
|
@interface RuSunInpdViewController ()
|
|
|
|
@end
|
|
|
|
@implementation RuSunInpdViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
self.tableView.dataSource =self;
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
|
|
|
if (section==0) {
|
|
|
|
return 1;
|
|
|
|
}else{
|
|
|
|
return 6;
|
|
}
|
|
}
|
|
|
|
-(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==5&&indexPath.section==1) {
|
|
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
|
|
|
|
}
|
|
NSArray *titles= @[@"S1",@"S2",@"S3",@"S4",@"USB灯",@"S5"];
|
|
if (indexPath.section==1) {
|
|
cell.chTitle.text = titles[indexPath.row];
|
|
}
|
|
|
|
//自定义名字
|
|
RunSunCHControl * ruSunch = [RunSunCHNameCustom 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.guideng;
|
|
}else if (indexPath.section==1&&indexPath.row==5){
|
|
cell.chName.text = ruSunch.jiaRe;
|
|
}
|
|
|
|
cell.chName.delegate = self;
|
|
cell.tag = 20000 + indexPath.row;
|
|
return cell;
|
|
}
|
|
|
|
-(void)sureAction
|
|
{
|
|
|
|
|
|
//RunSunCHNameCustom 本地处理 保存按钮名称 不与服务器交互
|
|
RunSunCHControl *ruSunch = [[RunSunCHControl 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:@"S3不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell3.chName.text.length==0) {
|
|
[self.view makeToast:@"S3不能为空"];
|
|
return;
|
|
}
|
|
|
|
ruSunch.ch3name = cell3.chName.text;
|
|
RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:RUSUNCHCELL_CH4];
|
|
if (cell4.chName.text.length>3) {
|
|
[self.view makeToast:@"S4不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell4.chName.text.length==0) {
|
|
[self.view makeToast:@"S4不能为空"];
|
|
return;
|
|
}
|
|
ruSunch.ch4name = cell4.chName.text;
|
|
|
|
|
|
RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:RUSUNCHCELL_GUIDENG];
|
|
if (cell5.chName.text.length>3) {
|
|
[self.view makeToast:@"USB灯不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell5.chName.text.length==0) {
|
|
[self.view makeToast:@"USB灯不能为空"];
|
|
return;
|
|
}
|
|
ruSunch.guideng = cell5.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell6 = [self.view viewWithTag:RUSUNCHCELL_JIARE];
|
|
if (cell6.chName.text.length>3) {
|
|
[self.view makeToast:@"S5名不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell6.chName.text.length==0) {
|
|
[self.view makeToast:@"S5名不能为空"];
|
|
return;
|
|
}
|
|
ruSunch.jiaRe = cell6.chName.text;
|
|
|
|
ruSunch.macAd = self.device.macAddress;
|
|
|
|
[RunSunCHNameCustom saveCHname:ruSunch];
|
|
|
|
[self upLoadDeviceName];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
#pragma mark - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
|
// Get the new view controller using [segue destinationViewController].
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
@end
|