一些事件绑定

This commit is contained in:
祝发冬 2023-08-20 18:32:01 +08:00
parent 6131f5ad5e
commit 878fe05931
2 changed files with 34 additions and 20 deletions

View File

@ -136,7 +136,7 @@ extern BOOL isfromCameraView;
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
self.navigationItem.backBarButtonItem = item; self.navigationItem.backBarButtonItem = item;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(viewWillEnterForeground:) name:Noti_WillEnterForeground object:nil];
[self creatConnectStateUI]; [self creatConnectStateUI];
//WiFi //WiFi
@ -171,6 +171,7 @@ extern BOOL isfromCameraView;
weakSelf.connectType = ConnectTypeAirKiss; weakSelf.connectType = ConnectTypeAirKiss;
weakSelf.connectTypeTitle.text = airkisTitle; weakSelf.connectTypeTitle.text = airkisTitle;
weakSelf.connectTipLbl.text = airkisTips; weakSelf.connectTipLbl.text = airkisTips;
[weakSelf.connectBtn setTitle:@"确定" forState:UIControlStateNormal];
}]; }];
@ -178,12 +179,14 @@ extern BOOL isfromCameraView;
weakSelf.connectType = ConnectTypeSmartESPTouch; weakSelf.connectType = ConnectTypeSmartESPTouch;
weakSelf.connectTypeTitle.text = smartTitle; weakSelf.connectTypeTitle.text = smartTitle;
weakSelf.connectTipLbl.text = smartTips; weakSelf.connectTipLbl.text = smartTips;
[weakSelf.connectBtn setTitle:@"确定" forState:UIControlStateNormal];
}]; }];
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 = ConnectTypeSmartESPTouch;
weakSelf.connectTypeTitle.text = apTitle; weakSelf.connectTypeTitle.text = apTitle;
weakSelf.connectTipLbl.text = apTips; weakSelf.connectTipLbl.text = apTips;
[weakSelf.connectBtn setTitle:@"下一步" forState:UIControlStateNormal];
}]; }];
SPAlertAction*cancel =[SPAlertAction actionWithTitle:@"取消" style:SPAlertActionStyleCancel handler:^(SPAlertAction * _Nonnull action) { SPAlertAction*cancel =[SPAlertAction actionWithTitle:@"取消" style:SPAlertActionStyleCancel handler:^(SPAlertAction * _Nonnull action) {
@ -214,19 +217,22 @@ extern BOOL isfromCameraView;
} }
//ap //ap
-(void)goSettingClick:(UIButton*)button -(IBAction)goSettingClick:(UIButton*)button
{ {
if(self.connectType == ConnectTypeAP)
{
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; if([[UIApplication sharedApplication] canOpenURL:url]) {
if (@available(iOS 10.0, *)) {
if([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
if (@available(iOS 10.0, *)) { }else {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; [[UIApplication sharedApplication] openURL:url];
}else { }
[[UIApplication sharedApplication] openURL:url]; self.isGoChangeWiFi = YES;
} }
self.isGoChangeWiFi = YES;
} }
} }
-(void)creatConnectStateUI{ -(void)creatConnectStateUI{
@ -419,10 +425,17 @@ extern BOOL isfromCameraView;
} }
[self savePassw]; [self savePassw];
[self configWifiForDevice]; if(self.connectType == ConnectTypeAP)
{
[self goSettingClick:nil];
}
{
[self configWifiForDevice];
// [self initMMProgressHUD];
[self connectNotNormalView];
}
// [self initMMProgressHUD];
[self connectNotNormalView];
if (_maclabel) { if (_maclabel) {
[_maclabel removeFromSuperview]; [_maclabel removeFromSuperview];
@ -678,6 +691,7 @@ extern BOOL isfromCameraView;
if (self.isGoChangeWiFi) { if (self.isGoChangeWiFi) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.35 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self checkWiFi]; [self checkWiFi];
self.isGoChangeWiFi = NO;
}); });
} }
@ -694,9 +708,6 @@ extern BOOL isfromCameraView;
[self.timer invalidate]; [self.timer invalidate];
self.timer = nil; self.timer = nil;
[self sendToDeviceWithSSIDName:self.ssid andSSIDPWD:self.wifiPass]; [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; self.navigationController.navigationBarHidden=NO;
} }
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:Noti_WillEnterForeground object:nil];
}
@end @end

View File

@ -134,7 +134,7 @@
<state key="normal" title="Button"/> <state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="查看联网失败的原因"/> <buttonConfiguration key="configuration" style="plain" title="查看联网失败的原因"/>
<connections> <connections>
<action selector="connectTypeClick:" destination="-1" eventType="touchUpInside" id="Pvi-dI-5am"/> <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 alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Bwm-2j-Hx2" userLabel="LINE4">
@ -162,7 +162,7 @@
</userDefinedRuntimeAttribute> </userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes> </userDefinedRuntimeAttributes>
<connections> <connections>
<action selector="connectTypeClick:" destination="-1" eventType="touchUpInside" id="R7q-Dy-WEB"/> <action selector="goSettingClick:" destination="-1" eventType="touchUpInside" id="ZiK-dY-8Ee"/>
</connections> </connections>
</button> </button>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="设备连接失败" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mZN-ia-LkX" userLabel="resultLabel"> <label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="设备连接失败" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mZN-ia-LkX" userLabel="resultLabel">