一些事件绑定

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

View File

@ -134,7 +134,7 @@
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="查看联网失败的原因"/>
<connections>
<action selector="connectTypeClick:" destination="-1" eventType="touchUpInside" id="Pvi-dI-5am"/>
<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">
@ -162,7 +162,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="connectTypeClick:" destination="-1" eventType="touchUpInside" id="R7q-Dy-WEB"/>
<action selector="goSettingClick:" destination="-1" eventType="touchUpInside" id="ZiK-dY-8Ee"/>
</connections>
</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">