版本和自动刷新

This commit is contained in:
祝发冬 2022-11-08 09:59:58 +08:00
parent 9f58af5f9c
commit 296e93272b
2 changed files with 34 additions and 28 deletions

View File

@ -16025,7 +16025,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = WFX8GD5HFX;
ENABLE_BITCODE = NO;
ENABLE_TESTABILITY = YES;
@ -16145,7 +16145,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 12;
CURRENT_PROJECT_VERSION = 13;
DEVELOPMENT_TEAM = WFX8GD5HFX;
ENABLE_BITCODE = NO;
ENABLE_TESTABILITY = YES;

View File

@ -198,6 +198,7 @@
self.heartCount=0;
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refresh) name:UIApplicationDidBecomeActiveNotification object:nil];
}
- (void)connect {
@ -211,34 +212,39 @@
self.scrollview.delegate = self;
__weak typeof (self)weakSelf=self;
[weakSelf.scrollview addRefreshHeaderViewWithAniViewClass:[JHRefreshAmazingAniView class] beginRefresh:^{
if (weakSelf.isRefeshing) {
return ;
}
weakSelf.isRefeshing=YES;
if (weakSelf.isconnect) {
searchDeviceModel*xinxiModel=[[searchDeviceModel alloc]init];
xinxiModel.resavemacId = self.currentDevice.macAddress;
xinxiModel.sendmacId = self.currentDevice.macAddress;
NSString*requestStr=xinxiModel.description;
NSLog(@"REQUEST = %@",requestStr);
NSData*data1=[dataContorl stringToHexData:requestStr];
[[Socketsingleton sharedInstance].clientSocket writeData:data1 withTimeout:-1 tag:0];
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
}else{// socket
[[Socketsingleton sharedInstance] cutOffSocket];
[weakSelf InitSocket];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf endRefreshing];
});
}
[weakSelf refresh];
}];
}
-(void)refresh
{
if (self.isRefeshing) {
return ;
}
self.isRefeshing=YES;
if (self.isconnect) {
searchDeviceModel*xinxiModel=[[searchDeviceModel alloc]init];
xinxiModel.resavemacId = self.currentDevice.macAddress;
xinxiModel.sendmacId = self.currentDevice.macAddress;
NSString*requestStr=xinxiModel.description;
NSLog(@"REQUEST = %@",requestStr);
NSData*data1=[dataContorl stringToHexData:requestStr];
[[Socketsingleton sharedInstance].clientSocket writeData:data1 withTimeout:-1 tag:0];
[[Socketsingleton sharedInstance].clientSocket readDataWithTimeout:-1 tag:0];
}else{// socket
[[Socketsingleton sharedInstance] cutOffSocket];
[self InitSocket];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self endRefreshing];
});
}
}
-(void)endRefreshing{
if (self.isRefeshing) {
self.isRefeshing=NO;
@ -1261,7 +1267,7 @@
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}