修改字数的限制

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

View File

@ -251,6 +251,10 @@
NSString *key = [NSString stringWithFormat:@"newXuTo%@",macaddress]; NSString *key = [NSString stringWithFormat:@"newXuTo%@",macaddress];
NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key]; NSString *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file]; XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if(!controlName.zaolangPump.length)
{
controlName.zaolangPump = @"换气";
}
if (!controlName||[controlName isKindOfClass:[NSNull class]]) { if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[XuToControlName alloc] init]; controlName = [[XuToControlName alloc] init];
controlName.shajunLight = @"杀菌灯"; controlName.shajunLight = @"杀菌灯";

View File

@ -20,6 +20,7 @@
@interface XuToControlNameViewController () @interface XuToControlNameViewController ()
@property (nonatomic,assign) BOOL isModify; @property (nonatomic,assign) BOOL isModify;
@end @end
@implementation XuToControlNameViewController @implementation XuToControlNameViewController
@ -27,6 +28,7 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
self.tableView.dataSource = self; self.tableView.dataSource = self;
} }
@ -205,9 +207,9 @@
} }
if ([cell.chTitle.text isEqualToString:@"照明"]) { 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; return;
} }
else if (cell.chName.text.length==0) else if (cell.chName.text.length==0)
@ -224,9 +226,9 @@
} }
else if ([cell.chTitle.text isEqualToString:@"换气"]) { 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; return;
} }
else if (cell.chName.text.length==0) else if (cell.chName.text.length==0)
@ -243,9 +245,9 @@
} }
else if ([cell.chTitle.text isEqualToString:@"杀菌"]) { 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; return;
} }
else if (cell.chName.text.length==0) else if (cell.chName.text.length==0)
@ -262,9 +264,9 @@
} }
else if ([cell.chTitle.text isEqualToString:@"恒温"]) { 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; return;
} }
else if (cell.chName.text.length==0) else if (cell.chName.text.length==0)
@ -294,11 +296,11 @@
} }
[set removeAllObjects]; [set removeAllObjects];
RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:XUTOCHCELL_AIR]; RuSunChangeNameTextViewCell*cell1 = [self.view viewWithTag:XUTOCHCELL_AIR];
if (cell1.chName.text.length>3) { if (cell1.chName.text.length>self.maxNameLength) {
if (_isNewdevice) { if (_isNewdevice) {
[self.view makeToast:@"杀菌灯不能超过3个字"]; [self.view makeToast:@"杀菌灯不能超过6个字"];
}else { }else {
[self.view makeToast:@"气泵不能超过3个字"]; [self.view makeToast:@"气泵不能超过6个字"];
} }
return; return;
} }
@ -317,11 +319,11 @@
} }
[set addObject:cell1.chName.text]; [set addObject:cell1.chName.text];
RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:XUTOCHCELL_LIANGHT1]; RuSunChangeNameTextViewCell*cell2 = [self.view viewWithTag:XUTOCHCELL_LIANGHT1];
if (cell2.chName.text.length>3) { if (cell2.chName.text.length>self.maxNameLength) {
if (_isNewdevice) { if (_isNewdevice) {
[self.view makeToast:@"增氧泵不能超过3个字"]; [self.view makeToast:@"增氧泵不能超过6个字"];
}else { }else {
[self.view makeToast:@"灯1不能超过3个字"]; [self.view makeToast:@"灯1不能超过6个字"];
} }
return; return;
} }
@ -340,11 +342,11 @@
} }
[set addObject:cell2.chName.text]; [set addObject:cell2.chName.text];
RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:XUTOCHCELL_LIANGHT2]; RuSunChangeNameTextViewCell*cell3 = [self.view viewWithTag:XUTOCHCELL_LIANGHT2];
if (cell3.chName.text.length>3) { if (cell3.chName.text.length>self.maxNameLength) {
if (_isNewdevice) { if (_isNewdevice) {
[self.view makeToast:@"灯光1不能超过3个字"]; [self.view makeToast:@"灯光1不能超过6个字"];
}else { }else {
[self.view makeToast:@"灯2不能超过3个字"]; [self.view makeToast:@"灯2不能超过6个字"];
} }
return; return;
} }
@ -363,11 +365,11 @@
} }
[set addObject:cell3.chName.text]; [set addObject:cell3.chName.text];
RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:XUTOCHCELL_HULI]; RuSunChangeNameTextViewCell*cell4 = [self.view viewWithTag:XUTOCHCELL_HULI];
if (cell4.chName.text.length>3) { if (cell4.chName.text.length>self.maxNameLength) {
if (_isNewdevice) { if (_isNewdevice) {
[self.view makeToast:@"灯光2不能超过3个字"]; [self.view makeToast:@"灯光2不能超过6个字"];
}else { }else {
[self.view makeToast:@"护理灯不能超过3个字"]; [self.view makeToast:@"护理灯不能超过6个字"];
} }
return; return;
} }
@ -386,11 +388,11 @@
} }
[set addObject:cell4.chName.text]; [set addObject:cell4.chName.text];
RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:XUTOCHCELL_WATER]; RuSunChangeNameTextViewCell*cell5 = [self.view viewWithTag:XUTOCHCELL_WATER];
if (cell5.chName.text.length>3) { if (cell5.chName.text.length>self.maxNameLength) {
if (_isNewdevice) { if (_isNewdevice) {
[self.view makeToast:@"造浪泵不能超过3个字"]; [self.view makeToast:@"造浪泵不能超过6个字"];
}else { }else {
[self.view makeToast:@"水泵不能超过3个字"]; [self.view makeToast:@"水泵不能超过6个字"];
} }
return; return;
} }
@ -409,11 +411,11 @@
} }
[set addObject:cell5.chName.text]; [set addObject:cell5.chName.text];
RuSunChangeNameTextViewCell*cell6 = [self.view viewWithTag:XUTOCHCELL_JIARE]; RuSunChangeNameTextViewCell*cell6 = [self.view viewWithTag:XUTOCHCELL_JIARE];
if (cell6.chName.text.length>3) { if (cell6.chName.text.length>self.maxNameLength) {
if (_isNewdevice) { if (_isNewdevice) {
[self.view makeToast:@"护理灯不能超过3个字"]; [self.view makeToast:@"护理灯不能超过6个字"];
}else { }else {
[self.view makeToast:@"加热棒不能超过3个字"]; [self.view makeToast:@"加热棒不能超过6个字"];
} }
return; return;
} }
@ -433,8 +435,8 @@
[set addObject:cell6.chName.text]; [set addObject:cell6.chName.text];
RuSunChangeNameTextViewCell*cell7 = [self.view viewWithTag:50006]; RuSunChangeNameTextViewCell*cell7 = [self.view viewWithTag:50006];
if (cell7) { if (cell7) {
if (cell7.chName.text.length>3) { if (cell7.chName.text.length>self.maxNameLength) {
[self.view makeToast:@"循环泵不能超过3个字"]; [self.view makeToast:@"循环泵不能超过6个字"];
return; return;
} }
if (cell7.chName.text.length==0) { if (cell7.chName.text.length==0) {
@ -448,8 +450,8 @@
RuSunChangeNameTextViewCell*cell8 = [self.view viewWithTag:50007]; RuSunChangeNameTextViewCell*cell8 = [self.view viewWithTag:50007];
if (cell8) { if (cell8) {
if (cell8.chName.text.length>3) { if (cell8.chName.text.length>self.maxNameLength) {
[self.view makeToast:@"加热棒不能超过3个字"]; [self.view makeToast:@"加热棒不能超过6个字"];
return; return;
} }
if (cell8.chName.text.length==0) { if (cell8.chName.text.length==0) {

View File

@ -133,9 +133,7 @@ static NSString *setTimerflag = @"SetTimerCell";
name.zengyangPump=@"蛋分器"; name.zengyangPump=@"蛋分器";
} }
// _titieArr = @[@"循环泵",@"增氧泵",@"灯光1",@"灯光2",@"造浪泵",@"杀菌灯"]; // _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]; _titieArr = @[name.xunhuanPump,name.zaolangPump,name.light1];
_imgArr = @[@"照明开",@"换气开",@"杀菌开"]; _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"];
}

View File

@ -17,6 +17,7 @@ typedef void (^deviceNameBlock)(NSString *);
@property (nonatomic,copy) NSString *name; @property (nonatomic,copy) NSString *name;
@property (nonatomic,copy) deviceNameBlock NameWithBlock ; @property (nonatomic,copy) deviceNameBlock NameWithBlock ;
@property(nonatomic,strong) DeviceModel* device; @property(nonatomic,strong) DeviceModel* device;
@property (nonatomic, assign) NSInteger maxNameLength;
-(UITableViewCell*)baseViewLoadDeviceNameCell:(NSIndexPath *)indexPath intable:(UITableView *)tableView; -(UITableViewCell*)baseViewLoadDeviceNameCell:(NSIndexPath *)indexPath intable:(UITableView *)tableView;
-(void)upLoadDeviceName; -(void)upLoadDeviceName;
//-(void)showGressView; //-(void)showGressView;

View File

@ -20,6 +20,7 @@
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
[self addTitleViewWithTitle:@"修改名称"]; [self addTitleViewWithTitle:@"修改名称"];
self.maxNameLength = 8;
UIButton *tureButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *tureButton = [UIButton buttonWithType:UIButtonTypeCustom];
tureButton.frame = CGRectMake(kScreenSize.width - 100, 10, 60, 60); tureButton.frame = CGRectMake(kScreenSize.width - 100, 10, 60, 60);
@ -159,7 +160,7 @@
[para setValue:userId forKey:@"priId.userId"]; [para setValue:userId forKey:@"priId.userId"];
[para setValue: cell.deviceName.text forKey:@"showName"]; [para setValue: cell.deviceName.text forKey:@"showName"];
if (cell.deviceName.text.length <= 6) { if (cell.deviceName.text.length <= self.maxNameLength) {
NSString*url=kUpdateDeviceUser; NSString*url=kUpdateDeviceUser;
if ([self.device.type isEqualToString:DECICE_TYPE_XUANDUO3F]) if ([self.device.type isEqualToString:DECICE_TYPE_XUANDUO3F])
{ {

View File

@ -197,7 +197,7 @@ extern BOOL isfromCameraView;
{ {
self.hidesBottomBarWhenPushed = YES; self.hidesBottomBarWhenPushed = YES;
ConAquarMethodVC *methodVC = InitObject(ConAquarMethodVC); ConfigWifiViewController *methodVC = [[ConfigWifiViewController alloc]init];
methodVC.deviceType=DEVICEPETS; methodVC.deviceType=DEVICEPETS;
methodVC.titleString=@"连接宠物笼"; methodVC.titleString=@"连接宠物笼";

View File

@ -24,6 +24,8 @@
@property (weak, nonatomic) IBOutlet UILabel *resultLabel; @property (weak, nonatomic) IBOutlet UILabel *resultLabel;
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *indicator; @property (weak, nonatomic) IBOutlet UIActivityIndicatorView *indicator;
@property (weak, nonatomic) IBOutlet UIView *line;
@property (nonatomic, strong) UIView *mask; @property (nonatomic, strong) UIView *mask;

View File

@ -101,7 +101,7 @@ extern BOOL isfromCameraView;
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
// Do any additional setup after loading the view from its nib. // Do any additional setup after loading the view from its nib.
[self addTitleViewWithTitle:self.titleString];
self.view.backgroundColor=[UIColor whiteColor]; self.view.backgroundColor=[UIColor whiteColor];
self.connectType = ConnectTypeAirKiss; self.connectType = ConnectTypeAirKiss;
_deviceArry =[[NSMutableArray alloc]init]; _deviceArry =[[NSMutableArray alloc]init];
@ -154,6 +154,17 @@ extern BOOL isfromCameraView;
-(void)viewDidDisappear:(BOOL)animated{ -(void)viewDidDisappear:(BOOL)animated{
[super viewDidDisappear:animated]; [super viewDidDisappear:animated];
}
-(void)goBackAction{
if(self.connectingView.hidden==NO)
{
[self connectNormalView];
}
else
{
[self.navigationController popViewControllerAnimated:YES];
}
} }
#pragma mark - #pragma mark -
@ -183,7 +194,7 @@ extern BOOL isfromCameraView;
}]; }];
SPAlertAction*ap =[SPAlertAction actionWithTitle:apTitle style:SPAlertActionStyleDefault handler:^(SPAlertAction * _Nonnull action) { SPAlertAction*ap =[SPAlertAction actionWithTitle:apTitle style:SPAlertActionStyleDefault handler:^(SPAlertAction * _Nonnull action) {
weakSelf.connectType = ConnectTypeSmartESPTouch; weakSelf.connectType = ConnectTypeAP;
weakSelf.connectTypeTitle.text = apTitle; weakSelf.connectTypeTitle.text = apTitle;
weakSelf.connectTipLbl.text = apTips; weakSelf.connectTipLbl.text = apTips;
[weakSelf.connectBtn setTitle:@"下一步" forState:UIControlStateNormal]; [weakSelf.connectBtn setTitle:@"下一步" forState:UIControlStateNormal];
@ -429,6 +440,7 @@ extern BOOL isfromCameraView;
{ {
[self goSettingClick:nil]; [self goSettingClick:nil];
} }
else
{ {
[self configWifiForDevice]; [self configWifiForDevice];
@ -713,6 +725,7 @@ extern BOOL isfromCameraView;
} }
- (void)sendToDeviceWithSSIDName:(NSString *)name andSSIDPWD:(NSString *)pwd { - (void)sendToDeviceWithSSIDName:(NSString *)name andSSIDPWD:(NSString *)pwd {
[self connectNotNormalView];
[IFishHotpotUDPHelper sharedInstance].delegate = self; [IFishHotpotUDPHelper sharedInstance].delegate = self;
[[IFishHotpotUDPHelper sharedInstance] broadCastHotspotConnectCommandWith:name pwd:pwd]; [[IFishHotpotUDPHelper sharedInstance] broadCastHotspotConnectCommandWith:name pwd:pwd];
} }
@ -726,7 +739,7 @@ extern BOOL isfromCameraView;
[self appendTrakContent:@"=================收到设备答复==================="]; [self appendTrakContent:@"=================收到设备答复==================="];
[self appendTrakContent:[NSString stringWithFormat:@"答复状态码:%@", backModel.result]]; [self appendTrakContent:[NSString stringWithFormat:@"答复状态码:%@", backModel.result]];
[self appendTrakContent:[NSString stringWithFormat:@"答复Mac地址:%@", backModel.senderMacAddress]]; [self appendTrakContent:[NSString stringWithFormat:@"答复Mac地址:%@", backModel.senderMacAddress]];
self.macAddress = backModel.senderMacAddress; self.deviceBssid = backModel.senderMacAddress;
[IFishHotpotUDPHelper sharedInstance].delegate = nil; [IFishHotpotUDPHelper sharedInstance].delegate = nil;
[[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand]; [[IFishHotpotUDPHelper sharedInstance] broadCastRestartCommand];
@ -747,7 +760,7 @@ extern BOOL isfromCameraView;
if (self.isBindingDevice||self.storeNameView) { if (self.isBindingDevice||self.storeNameView) {
return; return;
} }
if (self.macAddress.length == 0) { if (self.deviceBssid.length == 0) {
return; return;
} }
@ -758,7 +771,7 @@ extern BOOL isfromCameraView;
} }
else else
{ {
[self bindDeviceWithSsid:self.macAddress]; [self bindDeviceWithSsid:self.deviceBssid];
} }
} }
@ -844,6 +857,7 @@ extern BOOL isfromCameraView;
{ {
[self.storeNameView removeFromSuperview]; [self.storeNameView removeFromSuperview];
[self.mask removeFromSuperview]; [self.mask removeFromSuperview];
[self connectNormalView];
} }
-(void)showStoreNameView -(void)showStoreNameView
@ -859,6 +873,7 @@ extern BOOL isfromCameraView;
store.cancelBlock=^(){ store.cancelBlock=^(){
[weakSelf.mask removeFromSuperview]; [weakSelf.mask removeFromSuperview];
[weakSelf.storeNameView removeFromSuperview]; [weakSelf.storeNameView removeFromSuperview];
[weakSelf connectNormalView];
}; };
store.sureBlock=^(NSString*name) store.sureBlock=^(NSString*name)
@ -888,6 +903,7 @@ extern BOOL isfromCameraView;
else else
{ {
self.isBindingDevice = YES; self.isBindingDevice = YES;
[self connectNotNormalView];
if (self.bindTimer) { if (self.bindTimer) {
[self.bindTimer invalidate]; [self.bindTimer invalidate];
self.bindTimer = nil; self.bindTimer = nil;
@ -913,7 +929,7 @@ extern BOOL isfromCameraView;
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil]; NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSLog(@"data:%@",resultDic[@"data"]); NSLog(@"data:%@",resultDic[@"data"]);
self.isBindingDevice = NO; self.isBindingDevice = NO;
self.macAddress = nil; self.deviceBssid = nil;
if ([resultDic[@"result"] isEqualToString:@"100"]) { if ([resultDic[@"result"] isEqualToString:@"100"]) {
// //
@ -1016,7 +1032,7 @@ extern BOOL isfromCameraView;
if (self.retryTimes < 10) { if (self.retryTimes < 10) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
self.HUD.labelText = @"自动重连..."; self.HUD.labelText = @"自动重连...";
[self bindDeviceWithSsid:self.macAddress]; [self bindDeviceWithSsid:self.deviceBssid];
self.retryTimes += 1; self.retryTimes += 1;

View File

@ -18,6 +18,7 @@
<outlet property="connectTypeTitle" destination="D54-Zo-SRM" id="Rrc-ji-Mi6"/> <outlet property="connectTypeTitle" destination="D54-Zo-SRM" id="Rrc-ji-Mi6"/>
<outlet property="connectingView" destination="6tu-I5-SeJ" id="WWP-5J-epi"/> <outlet property="connectingView" destination="6tu-I5-SeJ" id="WWP-5J-epi"/>
<outlet property="indicator" destination="GB5-YX-lPF" id="6QA-Zj-USC"/> <outlet property="indicator" destination="GB5-YX-lPF" id="6QA-Zj-USC"/>
<outlet property="line" destination="Bwm-2j-Hx2" id="ULt-Jd-CMP"/>
<outlet property="reasonBtn" destination="AbO-MC-LqW" id="ylr-EB-OXe"/> <outlet property="reasonBtn" destination="AbO-MC-LqW" id="ylr-EB-OXe"/>
<outlet property="resultLabel" destination="mZN-ia-LkX" id="GbV-Ue-ryI"/> <outlet property="resultLabel" destination="mZN-ia-LkX" id="GbV-Ue-ryI"/>
<outlet property="shuoMingShuBtn" destination="a2I-Bk-68I" id="iYV-KF-6No"/> <outlet property="shuoMingShuBtn" destination="a2I-Bk-68I" id="iYV-KF-6No"/>
@ -137,7 +138,7 @@
<action selector="shuoMingShuBtnAction:" destination="-1" eventType="touchUpInside" id="nN3-mz-XkF"/> <action selector="shuoMingShuBtnAction:" destination="-1" eventType="touchUpInside" id="nN3-mz-XkF"/>
</connections> </connections>
</button> </button>
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bwm-2j-Hx2" userLabel="LINE4"> <view hidden="YES" alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bwm-2j-Hx2" userLabel="LINE4">
<rect key="frame" x="121.66666666666669" y="162" width="150" height="1"/> <rect key="frame" x="121.66666666666669" y="162" width="150" height="1"/>
<color key="backgroundColor" systemColor="systemGrayColor"/> <color key="backgroundColor" systemColor="systemGrayColor"/>
<constraints> <constraints>