131 lines
3.5 KiB
Objective-C
131 lines
3.5 KiB
Objective-C
//
|
|
// TwoControlNameViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 2017/6/14.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "TwoControlNameViewController.h"
|
|
#import "RuSunChangeNameTextViewCell.h"
|
|
#import "TwoControlName.h"
|
|
#import "UserExtendataArchaver.h"
|
|
#define TWOCHCELL_LIANGHT 20000
|
|
#define TWOCHCELL_PUMP 20001
|
|
@interface TwoControlNameViewController ()
|
|
|
|
@end
|
|
|
|
@implementation TwoControlNameViewController
|
|
|
|
- (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 2;
|
|
}
|
|
}
|
|
|
|
-(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==1&&indexPath.section==1) {
|
|
cell.lineImgView.image = [UIImage imageNamed:@"redact_line_last"];
|
|
|
|
}
|
|
NSArray *titles= @[@"灯1",@"水泵"];
|
|
if (indexPath.section==1) {
|
|
cell.chTitle.text = titles[indexPath.row];
|
|
}
|
|
|
|
//自定义名字
|
|
TwoControlName *name = [UserExtendataArchaver currentTwoControlName:self.device.macAddress];
|
|
if (indexPath.section==1&&indexPath.row==0) {
|
|
cell.chName.text = name.lightName;
|
|
|
|
}else if (indexPath.section==1&&indexPath.row==1){
|
|
cell.chName.text = name.pumpName;
|
|
}
|
|
cell.chName.delegate = self;
|
|
cell.tag = 20000 + indexPath.row;
|
|
return cell;
|
|
}
|
|
|
|
-(void)sureAction
|
|
{
|
|
|
|
|
|
//RunSunCHNameCustom 本地处理 保存按钮名称 不与服务器交互
|
|
TwoControlName *name = [[TwoControlName alloc] init];
|
|
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:TWOCHCELL_LIANGHT];
|
|
if (cell1.chName.text.length>3) {
|
|
[self.view makeToast:@"灯1不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell1.chName.text.length==0) {
|
|
[self.view makeToast:@"灯1不能为空"];
|
|
return;
|
|
}
|
|
name.lightName = cell1.chName.text;
|
|
|
|
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:TWOCHCELL_PUMP];
|
|
if (cell2.chName.text.length>3) {
|
|
[self.view makeToast:@"水泵不能超过3个字"];
|
|
return;
|
|
}
|
|
if (cell2.chName.text.length==0) {
|
|
[self.view makeToast:@"水泵不能为空"];
|
|
return;
|
|
}
|
|
name.pumpName = cell2.chName.text;
|
|
|
|
name.macAddress = self.device.macAddress;
|
|
[UserExtendataArchaver saveTwoControlName:name];
|
|
|
|
[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
|