UI修改读取定时

This commit is contained in:
kai60
2022-05-14 18:23:07 +08:00
parent e9992fed8b
commit 146e89a310
17 changed files with 424 additions and 153 deletions
BIN
View File
Binary file not shown.
+37
View File
@@ -0,0 +1,37 @@
//
// UIView+Frame.h
// FWChat
//
// Created by Yang on 16/1/25.
// Copyright © 2016年 Yang. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (Frame)
@property (nonatomic, assign) CGFloat x;
@property (nonatomic, assign) CGFloat y;
@property (nonatomic, assign) CGPoint origin;
@property (nonatomic, assign) CGSize size;
@property (nonatomic) CGFloat centerX;
@property (nonatomic) CGFloat centerY;
@property (nonatomic) CGFloat top;
@property (nonatomic) CGFloat bottom;
@property (nonatomic) CGFloat right;
@property (nonatomic) CGFloat left;
@property (nonatomic) CGFloat width;
@property (nonatomic) CGFloat height;
+ (instancetype)viewFromXib;
/** 设置锚点 */
- (void)setAnchorPoint:(CGPoint)anchorPoint;
/** 设回默认锚点 */
- (void)setDefaultAnchorPoint;
@end
+173
View File
@@ -0,0 +1,173 @@
//
// UIView+Frame.m
// FWChat
//
// Created by Yang on 16/1/25.
// Copyright © 2016年 Yang. All rights reserved.
//
#import "UIView+Frame.h"
@implementation UIView (Frame)
- (CGFloat)x
{
return self.frame.origin.x;
}
- (void)setX:(CGFloat)x
{
CGRect frame = self.frame;
frame.origin.x = x;
self.frame = frame;
}
- (CGFloat)y
{
return self.frame.origin.y;
}
- (void)setY:(CGFloat)y
{
CGRect frame = self.frame;
frame.origin.y = y;
self.frame = frame;
}
#pragma mark - Shortcuts for the coords
- (CGFloat)top
{
return self.frame.origin.y;
}
- (void)setTop:(CGFloat)y
{
CGRect frame = self.frame;
frame.origin.y = y;
self.frame = frame;
}
- (CGFloat)right
{
return self.frame.origin.x + self.frame.size.width;
}
- (void)setRight:(CGFloat)right
{
CGRect frame = self.frame;
frame.origin.x = right - self.frame.size.width;
self.frame = frame;
}
- (CGFloat)bottom
{
return self.frame.origin.y + self.frame.size.height;
}
- (void)setBottom:(CGFloat)bottom
{
CGRect frame = self.frame;
frame.origin.y = bottom - self.frame.size.height;
self.frame = frame;
}
- (CGFloat)left
{
return self.frame.origin.x;
}
- (void)setLeft:(CGFloat)x
{
CGRect frame = self.frame;
frame.origin.x = x;
self.frame = frame;
}
- (CGFloat)width
{
return self.frame.size.width;
}
- (void)setWidth:(CGFloat)width
{
CGRect frame = self.frame;
frame.size.width = width;
self.frame = frame;
}
- (CGFloat)height
{
return self.frame.size.height;
}
- (void)setHeight:(CGFloat)height
{
CGRect frame = self.frame;
frame.size.height = height;
self.frame = frame;
}
#pragma mark - Shortcuts for frame properties
- (CGPoint)origin {
return self.frame.origin;
}
- (void)setOrigin:(CGPoint)origin {
CGRect frame = self.frame;
frame.origin = origin;
self.frame = frame;
}
- (CGSize)size {
return self.frame.size;
}
- (void)setSize:(CGSize)size {
CGRect frame = self.frame;
frame.size = size;
self.frame = frame;
}
#pragma mark - Shortcuts for positions
- (CGFloat)centerX {
return self.center.x;
}
- (void)setCenterX:(CGFloat)centerX {
self.center = CGPointMake(centerX, self.center.y);
}
- (CGFloat)centerY {
return self.center.y;
}
- (void)setCenterY:(CGFloat)centerY {
self.center = CGPointMake(self.center.x, centerY);
}
+ (instancetype)viewFromXib
{
return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}
- (void)setAnchorPoint:(CGPoint)anchorPoint
{
CGPoint oldOrigin = self.frame.origin;
self.layer.anchorPoint = anchorPoint;
CGPoint newOrigin = self.frame.origin;
CGPoint transition;
transition.x = newOrigin.x - oldOrigin.x;
transition.y = newOrigin.y - oldOrigin.y;
self.center = CGPointMake (self.center.x - transition.x, self.center.y - transition.y);
}
- (void)setDefaultAnchorPoint
{
[self setAnchorPoint:CGPointMake(0.5f, 0.5f)];
}
@end
@@ -104,7 +104,7 @@
#pragma mark soket错误断开
-(void)onSocket:(AsyncSocket *)sock willDisconnectWithError:(NSError *)err{
NSLog(@"soket错误断开");
NSLog(@"soket错误断开:%@",err);
NSLog(@"存留数据%@",[sock unreadData]);
if (self.communiteDelegate&&[self.communiteDelegate respondsToSelector:@selector(ifishSocket:willDisconnectWithError:)]) {
[self.communiteDelegate ifishSocket:sock willDisconnectWithError:err];
@@ -135,7 +135,7 @@
[self.communiteDelegate ifishSocket:sock ifishSocketdidConnectToHost:host port:port];
}
NSLog(@"comm已经与服务器建立连接%d macAddress%@", self.clientSocket.isConnected,self.macAddress);
NSLog(@"服务器建立连接%d macAddress%@", self.clientSocket.isConnected,self.macAddress);
@@ -172,7 +172,7 @@
NSString*string1=[dataContorl dataToHexString:data];
NSString*string2=[string1 substringWithRange:NSMakeRange(30, 2)];
if ([string2 isEqualToString:@"01"]&&string1.length==52) {
NSLog(@"app登录成功");
// 查询
// AppDelegate*delegate=[[UIApplication sharedApplication]delegate];
@@ -180,6 +180,7 @@
[self getDeviceInfo];
if (self.communiteDelegate) {
NSLog(@"登录");
[self.communiteDelegate ifishDeviceLogInSuccees];
}
@@ -190,6 +191,7 @@
// [delegate.window makeToast:@"设备已离线"];
if (self.communiteDelegate) {
NSLog(@"离线");
[self.communiteDelegate ifishDeviceLogInFail];
}
@@ -203,7 +205,7 @@
}
NSLog(@"登陆成功后收到服务器的回执--->%@",data);
NSLog(@"readData--->%@",data);
}
@@ -252,7 +254,7 @@
-(void)soketWriteData:(NSData *)data{
[ self.clientSocket writeData:data withTimeout:-1 tag:0];
NSLog(@"manulData:%@",data);
NSLog(@"sendData:%@",data);
[self.clientSocket readDataWithTimeout:-1 tag:0];// 会出现接受服务器心跳包粘包问题
//[ self.singletonSocket.clientSocket readDataToLength:99 withTimeout:-1 tag:0];// 防止心跳包粘包