diff --git a/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m b/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m index 264f9f4..de132f6 100644 --- a/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m +++ b/Ifish/controllers/leftcontrollers/ConfigWifiViewController.m @@ -136,7 +136,7 @@ extern BOOL isfromCameraView; UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = item; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewWillEnterForeground:) name:Noti_WillEnterForeground object:nil]; [self creatConnectStateUI]; //获取WiFi名称 @@ -171,6 +171,7 @@ extern BOOL isfromCameraView; weakSelf.connectType = ConnectTypeAirKiss; weakSelf.connectTypeTitle.text = airkisTitle; weakSelf.connectTipLbl.text = airkisTips; + [weakSelf.connectBtn setTitle:@"确定" forState:UIControlStateNormal]; }]; @@ -178,12 +179,14 @@ extern BOOL isfromCameraView; weakSelf.connectType = ConnectTypeSmartESPTouch; weakSelf.connectTypeTitle.text = smartTitle; weakSelf.connectTipLbl.text = smartTips; + [weakSelf.connectBtn setTitle:@"确定" forState:UIControlStateNormal]; }]; SPAlertAction*ap =[SPAlertAction actionWithTitle:apTitle style:SPAlertActionStyleDefault handler:^(SPAlertAction * _Nonnull action) { weakSelf.connectType = ConnectTypeSmartESPTouch; weakSelf.connectTypeTitle.text = apTitle; weakSelf.connectTipLbl.text = apTips; + [weakSelf.connectBtn setTitle:@"下一步" forState:UIControlStateNormal]; }]; SPAlertAction*cancel =[SPAlertAction actionWithTitle:@"取消" style:SPAlertActionStyleCancel handler:^(SPAlertAction * _Nonnull action) { @@ -214,19 +217,22 @@ extern BOOL isfromCameraView; } //ap模式 --(void)goSettingClick:(UIButton*)button +-(IBAction)goSettingClick:(UIButton*)button { - - NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; - - if([[UIApplication sharedApplication] canOpenURL:url]) { - if (@available(iOS 10.0, *)) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - }else { - [[UIApplication sharedApplication] openURL:url]; + if(self.connectType == ConnectTypeAP) + { + NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; + + if([[UIApplication sharedApplication] canOpenURL:url]) { + if (@available(iOS 10.0, *)) { + [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; + }else { + [[UIApplication sharedApplication] openURL:url]; + } + self.isGoChangeWiFi = YES; } - self.isGoChangeWiFi = YES; } + } -(void)creatConnectStateUI{ @@ -419,10 +425,17 @@ extern BOOL isfromCameraView; } [self savePassw]; - [self configWifiForDevice]; + if(self.connectType == ConnectTypeAP) + { + [self goSettingClick:nil]; + } + { + [self configWifiForDevice]; - // [self initMMProgressHUD]; - [self connectNotNormalView]; + // [self initMMProgressHUD]; + [self connectNotNormalView]; + } + if (_maclabel) { [_maclabel removeFromSuperview]; @@ -678,6 +691,7 @@ extern BOOL isfromCameraView; if (self.isGoChangeWiFi) { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self checkWiFi]; + self.isGoChangeWiFi = NO; }); } @@ -694,9 +708,6 @@ extern BOOL isfromCameraView; [self.timer invalidate]; self.timer = nil; [self sendToDeviceWithSSIDName:self.ssid andSSIDPWD:self.wifiPass]; - // // Do any additional setup after loading the view. - self.timer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(timerAction) userInfo:nil repeats:YES]; - [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; }]; @@ -1117,6 +1128,9 @@ extern BOOL isfromCameraView; self.navigationController.navigationBarHidden=NO; } - +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self name:Noti_WillEnterForeground object:nil]; +} @end diff --git a/Ifish/controllers/leftcontrollers/ConfigWifiViewController.xib b/Ifish/controllers/leftcontrollers/ConfigWifiViewController.xib index 4480a49..e7d559c 100644 --- a/Ifish/controllers/leftcontrollers/ConfigWifiViewController.xib +++ b/Ifish/controllers/leftcontrollers/ConfigWifiViewController.xib @@ -134,7 +134,7 @@ - + @@ -162,7 +162,7 @@ - +