修改字数的限制

This commit is contained in:
祝发冬
2023-08-20 20:14:16 +08:00
parent 878fe05931
commit 189897a4f3
9 changed files with 74 additions and 43 deletions
@@ -20,6 +20,7 @@
@interface XuToControlNameViewController ()
@property (nonatomic,assign) BOOL isModify;
@end
@implementation XuToControlNameViewController
@@ -27,6 +28,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableView.dataSource = self;
}
@@ -205,9 +207,9 @@
}
if ([cell.chTitle.text isEqualToString:@"照明"]) {
if (cell.chName.text.length>3)
if (cell.chName.text.length>self.maxNameLength)
{
[self.view makeToast:@"照明不能超过3个字"];
[self.view makeToast:@"照明不能超过6个字"];
return;
}
else if (cell.chName.text.length==0)
@@ -224,9 +226,9 @@
}
else if ([cell.chTitle.text isEqualToString:@"换气"]) {
if (cell.chName.text.length>3)
if (cell.chName.text.length>self.maxNameLength)
{
[self.view makeToast:@"换气不能超过3个字"];
[self.view makeToast:@"换气不能超过6个字"];
return;
}
else if (cell.chName.text.length==0)
@@ -243,9 +245,9 @@
}
else if ([cell.chTitle.text isEqualToString:@"杀菌"]) {
if (cell.chName.text.length>3)
if (cell.chName.text.length>self.maxNameLength)
{
[self.view makeToast:@"杀菌不能超过3个字"];
[self.view makeToast:@"杀菌不能超过6个字"];
return;
}
else if (cell.chName.text.length==0)
@@ -262,9 +264,9 @@
}
else if ([cell.chTitle.text isEqualToString:@"恒温"]) {
if (cell.chName.text.length>3)
if (cell.chName.text.length>self.maxNameLength)
{
[self.view makeToast:@"恒温不能超过3个字"];
[self.view makeToast:@"恒温不能超过6个字"];
return;
}
else if (cell.chName.text.length==0)
@@ -294,11 +296,11 @@
}
[set removeAllObjects];
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:XUTOCHCELL_AIR];
if (cell1.chName.text.length>3) {
if (cell1.chName.text.length>self.maxNameLength) {
if (_isNewdevice) {
[self.view makeToast:@"杀菌灯不能超过3个字"];
[self.view makeToast:@"杀菌灯不能超过6个字"];
}else {
[self.view makeToast:@"气泵不能超过3个字"];
[self.view makeToast:@"气泵不能超过6个字"];
}
return;
}
@@ -317,11 +319,11 @@
}
[set addObject:cell1.chName.text];
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:XUTOCHCELL_LIANGHT1];
if (cell2.chName.text.length>3) {
if (cell2.chName.text.length>self.maxNameLength) {
if (_isNewdevice) {
[self.view makeToast:@"增氧泵不能超过3个字"];
[self.view makeToast:@"增氧泵不能超过6个字"];
}else {
[self.view makeToast:@"灯1不能超过3个字"];
[self.view makeToast:@"灯1不能超过6个字"];
}
return;
}
@@ -340,11 +342,11 @@
}
[set addObject:cell2.chName.text];
RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:XUTOCHCELL_LIANGHT2];
if (cell3.chName.text.length>3) {
if (cell3.chName.text.length>self.maxNameLength) {
if (_isNewdevice) {
[self.view makeToast:@"灯光1不能超过3个字"];
[self.view makeToast:@"灯光1不能超过6个字"];
}else {
[self.view makeToast:@"灯2不能超过3个字"];
[self.view makeToast:@"灯2不能超过6个字"];
}
return;
}
@@ -363,11 +365,11 @@
}
[set addObject:cell3.chName.text];
RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:XUTOCHCELL_HULI];
if (cell4.chName.text.length>3) {
if (cell4.chName.text.length>self.maxNameLength) {
if (_isNewdevice) {
[self.view makeToast:@"灯光2不能超过3个字"];
[self.view makeToast:@"灯光2不能超过6个字"];
}else {
[self.view makeToast:@"护理灯不能超过3个字"];
[self.view makeToast:@"护理灯不能超过6个字"];
}
return;
}
@@ -386,11 +388,11 @@
}
[set addObject:cell4.chName.text];
RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:XUTOCHCELL_WATER];
if (cell5.chName.text.length>3) {
if (cell5.chName.text.length>self.maxNameLength) {
if (_isNewdevice) {
[self.view makeToast:@"造浪泵不能超过3个字"];
[self.view makeToast:@"造浪泵不能超过6个字"];
}else {
[self.view makeToast:@"水泵不能超过3个字"];
[self.view makeToast:@"水泵不能超过6个字"];
}
return;
}
@@ -409,11 +411,11 @@
}
[set addObject:cell5.chName.text];
RuSunChangeNameTextViewCell*cell6 = [self.view viewWithTag:XUTOCHCELL_JIARE];
if (cell6.chName.text.length>3) {
if (cell6.chName.text.length>self.maxNameLength) {
if (_isNewdevice) {
[self.view makeToast:@"护理灯不能超过3个字"];
[self.view makeToast:@"护理灯不能超过6个字"];
}else {
[self.view makeToast:@"加热棒不能超过3个字"];
[self.view makeToast:@"加热棒不能超过6个字"];
}
return;
}
@@ -433,8 +435,8 @@
[set addObject:cell6.chName.text];
RuSunChangeNameTextViewCell*cell7 = [self.view viewWithTag:50006];
if (cell7) {
if (cell7.chName.text.length>3) {
[self.view makeToast:@"循环泵不能超过3个字"];
if (cell7.chName.text.length>self.maxNameLength) {
[self.view makeToast:@"循环泵不能超过6个字"];
return;
}
if (cell7.chName.text.length==0) {
@@ -448,8 +450,8 @@
RuSunChangeNameTextViewCell*cell8 = [self.view viewWithTag:50007];
if (cell8) {
if (cell8.chName.text.length>3) {
[self.view makeToast:@"加热棒不能超过3个字"];
if (cell8.chName.text.length>self.maxNameLength) {
[self.view makeToast:@"加热棒不能超过6个字"];
return;
}
if (cell8.chName.text.length==0) {
@@ -133,9 +133,7 @@ static NSString *setTimerflag = @"SetTimerCell";
name.zengyangPump=@"蛋分器";
}
// _titieArr = @[@"循环泵",@"增氧泵",@"灯光1",@"灯光2",@"造浪泵",@"杀菌灯"];
_titieArr = @[name.xunhuanPump,name.zengyangPump,name.light1,name.light2,name.zaolangPump,name.shajunLight];
_imgArr = @[@"xunhuan_big",@"gas_big",@"light_big",@"light_big",@"wave_big",@"shajun_big"];
@@ -144,6 +142,12 @@ static NSString *setTimerflag = @"SetTimerCell";
_titieArr = @[name.xunhuanPump,name.zaolangPump,name.light1];
_imgArr = @[@"照明开",@"换气开",@"杀菌开"];
}
else
{
_titieArr = @[name.xunhuanPump,name.zengyangPump,name.light1,name.light2,name.zaolangPump,name.shajunLight];
_imgArr = @[@"xunhuan_big",@"gas_big",@"light_big",@"light_big",@"wave_big",@"shajun_big"];
}
@@ -17,6 +17,7 @@ typedef void (^deviceNameBlock)(NSString *);
@property (nonatomic,copy) NSString *name;
@property (nonatomic,copy) deviceNameBlock NameWithBlock ;
@property(nonatomic,strong) DeviceModel* device;
@property (nonatomic, assign) NSInteger maxNameLength;
-(UITableViewCell*)baseViewLoadDeviceNameCell:(NSIndexPath *)indexPath intable:(UITableView *)tableView;
-(void)upLoadDeviceName;
//-(void)showGressView;
@@ -20,6 +20,7 @@
[super viewDidLoad];
// Do any additional setup after loading the view.
[self addTitleViewWithTitle:@"修改名称"];
self.maxNameLength = 8;
UIButton *tureButton = [UIButton buttonWithType:UIButtonTypeCustom];
tureButton.frame = CGRectMake(kScreenSize.width - 100, 10, 60, 60);
@@ -159,7 +160,7 @@
[para setValue:userId forKey:@"priId.userId"];
[para setValue: cell.deviceName.text forKey:@"showName"];
if (cell.deviceName.text.length <= 6) {
if (cell.deviceName.text.length <= self.maxNameLength) {
NSString*url=kUpdateDeviceUser;
if ([self.device.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{