修改字数的限制

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 *file = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject stringByAppendingPathComponent:key];
XuToControlName *controlName = [NSKeyedUnarchiver unarchiveObjectWithFile:file];
if(!controlName.zaolangPump.length)
{
controlName.zaolangPump = @"换气";
}
if (!controlName||[controlName isKindOfClass:[NSNull class]]) {
controlName = [[XuToControlName alloc] init];
controlName.shajunLight = @"杀菌灯";

View File

@ -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) {

View File

@ -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"];
}

View File

@ -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;

View File

@ -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])
{

View File

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

View File

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

View File

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

View File

@ -18,6 +18,7 @@
<outlet property="connectTypeTitle" destination="D54-Zo-SRM" id="Rrc-ji-Mi6"/>
<outlet property="connectingView" destination="6tu-I5-SeJ" id="WWP-5J-epi"/>
<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="resultLabel" destination="mZN-ia-LkX" id="GbV-Ue-ryI"/>
<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"/>
</connections>
</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"/>
<color key="backgroundColor" systemColor="systemGrayColor"/>
<constraints>