Commit 1af17113 by 徐利超

update

parent affe3e2a
......@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
401233CC25636AC5001C8EEB /* POCLoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 401233CB25636AC5001C8EEB /* POCLoginViewController.m */; };
402C16CD24222A6A00F6EA72 /* AutoFaceDetectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 402C16CC24222A6A00F6EA72 /* AutoFaceDetectionViewController.m */; };
402C16DA242352EC00F6EA72 /* ImageShowViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 402C16D9242352EC00F6EA72 /* ImageShowViewController.m */; };
402C16F424236D9B00F6EA72 /* UIAlertController+Extend.m in Sources */ = {isa = PBXBuildFile; fileRef = 402C16DE24236D9B00F6EA72 /* UIAlertController+Extend.m */; };
......@@ -104,6 +105,9 @@
40F6FA7623D6E58E00EC3737 /* MutiFaceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 40F6FA7523D6E58E00EC3737 /* MutiFaceViewController.m */; };
40F6FA7E23E973F500EC3737 /* MutiFaceContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40F6FA7D23E973F500EC3737 /* MutiFaceContainerView.m */; };
40F6FA8023E97F0300EC3737 /* Settings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 40F6FA7F23E97F0300EC3737 /* Settings.bundle */; };
40FB44A0254EADF800AACEEE /* WKWebView+YUNXINSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FB449F254EADF700AACEEE /* WKWebView+YUNXINSwizzle.m */; };
40FB44A6254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FB44A5254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.m */; };
40FB44AD25524ECB00AACEEE /* UIWebView+YUNXINSwizzie.m in Sources */ = {isa = PBXBuildFile; fileRef = 40FB44AC25524ECA00AACEEE /* UIWebView+YUNXINSwizzie.m */; };
901AFCC6973CC2B29B1AFF5C /* Pods_MutiFaceDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9E636B910955FD5DD32F0DCE /* Pods_MutiFaceDemo.framework */; };
/* End PBXBuildFile section */
......@@ -143,6 +147,8 @@
/* Begin PBXFileReference section */
0FF6405992EDB934F6CDB0E3 /* Pods-MutiFaceDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MutiFaceDemo.release.xcconfig"; path = "Target Support Files/Pods-MutiFaceDemo/Pods-MutiFaceDemo.release.xcconfig"; sourceTree = "<group>"; };
401233CA25636AC5001C8EEB /* POCLoginViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = POCLoginViewController.h; sourceTree = "<group>"; };
401233CB25636AC5001C8EEB /* POCLoginViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = POCLoginViewController.m; sourceTree = "<group>"; };
402C16CB24222A6A00F6EA72 /* AutoFaceDetectionViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AutoFaceDetectionViewController.h; sourceTree = "<group>"; };
402C16CC24222A6A00F6EA72 /* AutoFaceDetectionViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AutoFaceDetectionViewController.m; sourceTree = "<group>"; };
402C16D8242352EC00F6EA72 /* ImageShowViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageShowViewController.h; sourceTree = "<group>"; };
......@@ -314,6 +320,12 @@
40F6FA7C23E973F500EC3737 /* MutiFaceContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MutiFaceContainerView.h; sourceTree = "<group>"; };
40F6FA7D23E973F500EC3737 /* MutiFaceContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MutiFaceContainerView.m; sourceTree = "<group>"; };
40F6FA7F23E97F0300EC3737 /* Settings.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Settings.bundle; sourceTree = "<group>"; };
40FB449E254EADF700AACEEE /* WKWebView+YUNXINSwizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WKWebView+YUNXINSwizzle.h"; sourceTree = "<group>"; };
40FB449F254EADF700AACEEE /* WKWebView+YUNXINSwizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WKWebView+YUNXINSwizzle.m"; sourceTree = "<group>"; };
40FB44A4254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "WKUserContentController+YUNXINSwizzle.h"; sourceTree = "<group>"; };
40FB44A5254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "WKUserContentController+YUNXINSwizzle.m"; sourceTree = "<group>"; };
40FB44AB25524ECA00AACEEE /* UIWebView+YUNXINSwizzie.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIWebView+YUNXINSwizzie.h"; sourceTree = "<group>"; };
40FB44AC25524ECA00AACEEE /* UIWebView+YUNXINSwizzie.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIWebView+YUNXINSwizzie.m"; sourceTree = "<group>"; };
9E636B910955FD5DD32F0DCE /* Pods_MutiFaceDemo.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MutiFaceDemo.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E8FDB7899269DB88599AB6D9 /* Pods-MutiFaceDemo.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MutiFaceDemo.debug.xcconfig"; path = "Target Support Files/Pods-MutiFaceDemo/Pods-MutiFaceDemo.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -580,6 +592,12 @@
40F58B2B2533FB960087C93F /* YUNXINSameScreenView.h */,
40F58B2C2533FB960087C93F /* YUNXINSameScreenView.m */,
40F58B2E25342CB60087C93F /* YUNXINSameScreenDefine.h */,
40FB449E254EADF700AACEEE /* WKWebView+YUNXINSwizzle.h */,
40FB449F254EADF700AACEEE /* WKWebView+YUNXINSwizzle.m */,
40FB44AB25524ECA00AACEEE /* UIWebView+YUNXINSwizzie.h */,
40FB44AC25524ECA00AACEEE /* UIWebView+YUNXINSwizzie.m */,
40FB44A4254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.h */,
40FB44A5254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.m */,
);
path = YUNXINSameScreen;
sourceTree = "<group>";
......@@ -672,6 +690,8 @@
children = (
40F6F9CE23D698AC00EC3737 /* LoginViewController.h */,
40F6F9CF23D698AC00EC3737 /* LoginViewController.m */,
401233CA25636AC5001C8EEB /* POCLoginViewController.h */,
401233CB25636AC5001C8EEB /* POCLoginViewController.m */,
);
path = loginViewController;
sourceTree = "<group>";
......@@ -1139,10 +1159,13 @@
40F6F99E23D696CF00EC3737 /* ViewController.m in Sources */,
40F6FA5223D6B36A00EC3737 /* shader.c in Sources */,
40F6FA5723D6B36A00EC3737 /* rgb.fsh.c in Sources */,
40FB44A0254EADF800AACEEE /* WKWebView+YUNXINSwizzle.m in Sources */,
40F6F99823D696CF00EC3737 /* AppDelegate.m in Sources */,
402C16FE24236D9B00F6EA72 /* LHSIDCardScaningView.m in Sources */,
40F6F9F923D6B2FC00EC3737 /* MBHUDTool.m in Sources */,
40FB44A6254FE85C00AACEEE /* WKUserContentController+YUNXINSwizzle.m in Sources */,
402C16F524236D9B00F6EA72 /* UIImage+Extend.m in Sources */,
401233CC25636AC5001C8EEB /* POCLoginViewController.m in Sources */,
40F6FA5323D6B36A00EC3737 /* renderer.c in Sources */,
40F58B2925304C730087C93F /* YUNXINSameScreenManager.m in Sources */,
40F6F9A923D696D600EC3737 /* main.m in Sources */,
......@@ -1150,6 +1173,7 @@
40F6FA4E23D6B36A00EC3737 /* mvp.vsh.c in Sources */,
40F6FA4323D6B36A00EC3737 /* NTESClientUtil.m in Sources */,
40F6FA4423D6B36A00EC3737 /* NTESNotificationCenter.m in Sources */,
40FB44AD25524ECB00AACEEE /* UIWebView+YUNXINSwizzie.m in Sources */,
409E0C412424B1F200892138 /* UIColor+CH.m in Sources */,
40F58B31253554380087C93F /* YUNXINDemoViewController.m in Sources */,
40F58B062521B3820087C93F /* CHShadeView.m in Sources */,
......
......@@ -12,8 +12,10 @@
#import "NTESCustomAttachmentDecoder.h"
#import "NTESService.h"
#import "NTESNotificationCenter.h"
#import "POCLoginViewController.h"
#import "IQKeyboardManager.h"
#define NIMAppKey @"4ea930ab3d6fb1f3613e9877332c9dd9"
//#define NIMAppKey @"4ea930ab3d6fb1f3613e9877332c9dd9"
//本地化key
//#define NIMAppKey @"b6c92438c06f98a909ae45bf21bf2842"
//蜂巢
......@@ -30,8 +32,12 @@
// Override point for customization after application launch.
// [[NIMAVChatSDK sharedSDK] serverSetting];
NIMSDKOption *option = [NIMSDKOption optionWithAppKey:NIMAppKey];
[[NIMSDK sharedSDK] registerWithOption:option];
// NIMSDKOption *option = [NIMSDKOption optionWithAppKey:NIMAppKey];
// [[NIMSDK sharedSDK] registerWithOption:option];
[[IQKeyboardManager sharedManager] setEnable:YES];
[IQKeyboardManager sharedManager].enableAutoToolbar = NO;
[IQKeyboardManager sharedManager].shouldResignOnTouchOutside = YES;
[[NTESNotificationCenter sharedCenter] start];
//注册自定义消息的解析器
......@@ -41,7 +47,8 @@
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
}
if (!self.window.rootViewController) {
LoginViewController *loginVC = [[LoginViewController alloc] init];
POCLoginViewController *loginVC = [[POCLoginViewController alloc] init];
// LoginViewController *loginVC = [[LoginViewController alloc] init];
self.window.rootViewController = loginVC;
[self.window makeKeyAndVisible];
}
......
......@@ -23,7 +23,7 @@ dispatch_async(dispatch_get_main_queue(), block);\
}
@interface CHFacesignWebView ()<CHShadeViewDelegate, UIScrollViewDelegate, YWScrawlViewDelegate, WKUIDelegate, WKNavigationDelegate>
@interface CHFacesignWebView ()<CHShadeViewDelegate, UIScrollViewDelegate, YWScrawlViewDelegate, WKUIDelegate, WKNavigationDelegate,WKScriptMessageHandler>
{
NSTimer *heartBeat;
}
......
......@@ -9,11 +9,16 @@
#import "YUNXINDemoView.h"
#import "YUNXINSameScreenManager.h"
#import "CHUIFactory.h"
#import <WebKit/WebKit.h>
@interface YUNXINDemoView ()
@interface YUNXINDemoView ()<UIScrollViewDelegate, WKUIDelegate, WKNavigationDelegate, WKScriptMessageHandler,UIWebViewDelegate>
@property (nonatomic, strong) UIView *sameScrennView;
@property (nonatomic, strong) WKWebView *webView;
@property (nonatomic, strong) UIWebView *uiWebView;
@property (nonatomic, assign) BOOL isAnimated;
@property (nonatomic, strong) UIView *toolBarView;
@property (nonatomic, strong) UIButton *cancelBtn;
......@@ -42,12 +47,24 @@
- (void)setupUI
{
self.sameScrennView = [[YUNXINSameScreenManager shareInstance] getSameScreenViewWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight) drawHexColor:@"#000000" isManager:YES];
[[YUNXINSameScreenManager shareInstance] updateSameScreenViewWithWebUrl:@"http://192.168.70.182/glw/005_teamwork/private.html?v=1" miniFlag:@"1"];
// self.sameScrennView = [[YUNXINSameScreenManager shareInstance] getSameScreenViewWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight) drawHexColor:@"#000000" isManager:YES];
self.sameScrennView = [[YUNXINSameScreenManager shareInstance] getSameScreenViewWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight) webView:self.webView drawHexColor:@"#000000" isManager:YES];
[[YUNXINSameScreenManager shareInstance] updateSameScreenViewWithWebUrl:@"http://192.168.70.182/glw/005_teamwork/private.html?12" miniFlag:@"1"];
[self addSubview:self.sameScrennView];
[self addSubview:self.toolBarView];
[_webView.configuration.userContentController addScriptMessageHandler:self name:@"sendJS2Native"];
}
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
{
if ([message.name isEqualToString:@"Share"]) {
}
TraceS(@"====== >>>> Native : %@",message.name);
}
- (void)updateToolBarViewWithshowArray:(NSArray *)showArray
......@@ -161,6 +178,23 @@
[[YUNXINSameScreenManager shareInstance] undoCanvas];
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
CGFloat y = scrollView.contentOffset.y;
TraceS(@"=====>>>>> Native scrollView scrollHeight : %f", y);
// if (scrollView.tracking || scrollView.dragging || scrollView.decelerating) {
// CGFloat y = scrollView.contentOffset.y;
// TraceS(@"=====>>>>> Native scrollView scrollHeight : %f", y);
// }
}
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
TraceS(@"=====>>>>> Native decidePolicyForNavigationAction");
decisionHandler(WKNavigationActionPolicyAllow);
}
#pragma mark - setter/getter
- (UIView *)toolBarView
{
......@@ -211,4 +245,36 @@
return _undoBtn;
}
- (WKWebView *)webView
{
if (!_webView){
WKWebViewConfiguration *webConfig = [[WKWebViewConfiguration alloc] init];
// 设置偏好设置
webConfig.preferences = [[WKPreferences alloc] init];
// 默认为0
webConfig.preferences.minimumFontSize = 10;
// 默认认为YES
webConfig.preferences.javaScriptEnabled = YES;
// 在iOS上默认为NO,表示不能自动通过窗口打开
webConfig.preferences.javaScriptCanOpenWindowsAutomatically = YES;
webConfig.userContentController = [WKUserContentController new];
_webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight) configuration:webConfig];
_webView.backgroundColor = [UIColor colorWithRed:246.0/255 green:246.0/255 blue:246.0/255 alpha:1.0];
_webView.scrollView.delegate = self;
_webView.UIDelegate = self;
_webView.navigationDelegate = self;
}
return _webView;
}
- (UIWebView *)uiWebView
{
if (!_uiWebView) {
_uiWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - kStatusBarHeight - 40 - kSafeButtomHeight)];
_uiWebView.delegate = self;
}
return _uiWebView;
}
@end
......@@ -43,13 +43,13 @@
- (void)sameScreenBtnTouched
{
// [_demoView show];
// [[YUNXINSameScreenManager shareInstance] beginSameScreenAction];
// _noticeLabel.hidden = YES;
// _hangupBtn.hidden = YES;
// _sameScreenBtn.hidden = YES;
// _isShow = YES;
[[YUNXINSameScreenManager shareInstance] requestForSameScreen];
[_demoView show];
[[YUNXINSameScreenManager shareInstance] beginSameScreenAction];
_noticeLabel.hidden = YES;
_hangupBtn.hidden = YES;
_sameScreenBtn.hidden = YES;
_isShow = YES;
// [[YUNXINSameScreenManager shareInstance] requestForSameScreen];
}
......@@ -134,6 +134,17 @@
[_demoView updateToolBarWhenSameScreenAuthority:YES];
}
- (void)sameScreenOperateH5ByOther:(NSDictionary *)param
{
NSLog(@"===== >>>>> 别人操作了:%@",param);
}
- (void)sameScreenOperateH5BySelf:(NSDictionary *)param
{
NSLog(@"===== >>>>> 自己操作了:%@",param);
}
#pragma mark - YUNXINDemoViewDelegate
- (void)demoViewDismiss
{
......
//
// UIScrollView+YUNXINSwizzle.h
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/1.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIScrollView (YUNXINSwizzle)
@end
NS_ASSUME_NONNULL_END
//
// UIScrollView+YUNXINSwizzle.m
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/1.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import "UIScrollView+YUNXINSwizzle.h"
#import <objc/runtime.h>
// UIScrollViewDelegate代理方法所有的C方法实现
void (*origin_scrollViewDidScroll)(id, SEL, UIScrollView*);
void exchange_scrollViewDidScroll(id self, SEL _cmd, UIScrollView *scrollView) {
if (origin_scrollViewDidScroll) {
origin_scrollViewDidScroll(self, _cmd, scrollView);
}
CGFloat y = scrollView.contentOffset.y;
TraceS(@"=====>>>>> exchange scrollView scrollHeight : %f", y);
}
static NSMutableArray *arrayM;
@implementation UIScrollView (YUNXINSwizzle)
+ (void)load{
Method originalMethod = class_getInstanceMethod([UIScrollView class], @selector(setDelegate:));
Method swizzledMethod = class_getInstanceMethod([UIScrollView class], @selector(hook_setDelegate:));
method_exchangeImplementations(originalMethod, swizzledMethod);
arrayM = [NSMutableArray array];
}
- (void)hook_setDelegate:(id<UIScrollViewDelegate>)delegate{
[self hook_setDelegate:delegate];
// 获取delegate实际的类 (每个代理类只能调用一次 否则就会循环引用)
Class aClass = [delegate class];
NSLog(@"delegateClass = %@", aClass);
if ([arrayM containsObject:aClass]) {
NSLog(@"return class = %@", aClass);
return;
}else{
[arrayM addObject:aClass];
}
// 保留原方法 并将新方法的IMP指向原方法
[self exchangeDelegateOfOriginClass:aClass];
}
/**交互原类中相关的代理方法*/
- (void)exchangeDelegateOfOriginClass:(Class)cls{
// scrollViewDidScroll
SEL originSel = @selector(scrollViewDidScroll:);
Method originMethod = class_getInstanceMethod(cls, originSel);
origin_scrollViewDidScroll = (void*)method_getImplementation(originMethod);
// NSLog(@"%s - %s - %s - %s",@encode(BOOL),@encode(UIWebView),@encode(NSURLRequest),@encode(UIWebViewNavigationType));
// B返回bool值, @表示id类型, :表示方法类型, b表示long long类型, 所以 B(返回值)@:@(第一个参数)@(第二个参数)b(第三个参数)
if (!class_addMethod(cls, originSel, (IMP)exchange_scrollViewDidScroll, "v@:@")) {// 没有添加成功, 表示方法已经在原类中存在了
method_setImplementation(originMethod, (IMP)exchange_scrollViewDidScroll);
}
}
@end
//
// UIWebView+YUNXINSwizzie.h
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/4.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UIWebView (YUNXINSwizzie)
@end
NS_ASSUME_NONNULL_END
//
// UIWebView+YUNXINSwizzie.m
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/4.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import "UIWebView+YUNXINSwizzie.h"
#import <objc/runtime.h>
//- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType API_DEPRECATED("No longer supported.", ios(2.0, 12.0));
// UIScrollViewDelegate代理方法所有的C方法实现
void (*origin_webviewshouldStartLoadWithRequest)(id, SEL, UIWebView*, NSURLRequest*, UIWebViewNavigationType);
void exchange_webviewshouldStartLoadWithRequest(id self, SEL _cmd, UIWebView *webView, NSURLRequest *request, UIWebViewNavigationType navigationType) {
if (origin_webviewshouldStartLoadWithRequest) {
origin_webviewshouldStartLoadWithRequest(self, _cmd, webView, request, navigationType);
}
TraceS(@"=====>>>>> exchange UIwebViewAction");
}
static NSMutableArray *arrayM;
@implementation UIWebView (YUNXINSwizzie)
+ (void)load{
Method originalMethod = class_getInstanceMethod([UIWebView class], @selector(setDelegate:));
Method swizzledMethod = class_getInstanceMethod([UIWebView class], @selector(hook_setDelegate:));
method_exchangeImplementations(originalMethod, swizzledMethod);
arrayM = [NSMutableArray array];
}
- (void)hook_setDelegate:(id<UIWebViewDelegate>)delegate{
[self hook_setDelegate:delegate];
// 获取delegate实际的类 (每个代理类只能调用一次 否则就会循环引用)
Class aClass = [delegate class];
NSLog(@"delegateClass = %@", aClass);
if ([arrayM containsObject:aClass]) {
NSLog(@"return class = %@", aClass);
return;
}else{
[arrayM addObject:aClass];
}
// 保留原方法 并将新方法的IMP指向原方法
[self exchangeDelegateOfOriginClass:aClass];
}
/**交互原类中相关的代理方法*/
- (void)exchangeDelegateOfOriginClass:(Class)cls{
// scrollViewDidScroll
SEL originSel = @selector(webView:shouldStartLoadWithRequest:navigationType:);
Method originMethod = class_getInstanceMethod(cls, originSel);
origin_webviewshouldStartLoadWithRequest = (void*)method_getImplementation(originMethod);
//// NSLog(@"%s - %s - %s - %s",@encode(BOOL),@encode(UIWebView),@encode(NSURLRequest),@encode(UIWebViewNavigationType));
// B返回bool值, @表示id类型, :表示方法类型, b表示long long类型, 所以 B(返回值)@:@(第一个参数)@(第二个参数)b(第三个参数)
if (!class_addMethod(cls, originSel, (IMP)exchange_webviewshouldStartLoadWithRequest, "B@:@@b")) {// 没有添加成功, 表示方法已经在原类中存在了
method_setImplementation(originMethod, (IMP)exchange_webviewshouldStartLoadWithRequest);
}
//
}
@end
//
// WKUserContentController+YUNXINSwizzle.h
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/2.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKUserContentController (YUNXINSwizzle)
@end
NS_ASSUME_NONNULL_END
//
// WKUserContentController+YUNXINSwizzle.m
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/2.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import "WKUserContentController+YUNXINSwizzle.h"
#import <objc/runtime.h>
#import "YUNXINSameScreenManager.h"
#import "YUNXINSameScreenDefine.h"
// UIScrollViewDelegate代理方法所有的C方法实现
void (*origin_userContentControllerDidReceiveScriptMessage)(id, SEL, WKUserContentController*, WKScriptMessage*);
void exchange_userContentControllerDidReceiveScriptMessage(id self, SEL _cmd, WKUserContentController *userContentController, WKScriptMessage *message) {
if (origin_userContentControllerDidReceiveScriptMessage) {
origin_userContentControllerDidReceiveScriptMessage(self, _cmd,userContentController, message);
}
if ([message.name isEqualToString:@"sendJS2Native"]) {
[[YUNXINSameScreenManager shareInstance] sendCustomSysMsgWithParam:message.body action:SameScreenSyncH5];
}
TraceS(@"=====>>>>> exchange userContentControllerDidReceiveScriptMessage");
}
static NSMutableArray *arrayM;
@implementation WKUserContentController (YUNXINSwizzle)
+ (void)load{
Method originalMethod = class_getInstanceMethod([WKUserContentController class], @selector(addScriptMessageHandler:name:));
Method swizzledMethod = class_getInstanceMethod([WKUserContentController class], @selector(hook_addScriptMessageHandler:name:));
method_exchangeImplementations(originalMethod, swizzledMethod);
arrayM = [NSMutableArray array];
}
- (void)hook_addScriptMessageHandler:(id<WKScriptMessageHandler>)scriptMessageHandler name:(NSString *)name{
[self hook_addScriptMessageHandler:scriptMessageHandler name:name];
// 获取delegate实际的类 (每个代理类只能调用一次 否则就会循环引用)
Class aClass = [scriptMessageHandler class];
NSLog(@"delegateClass = %@", aClass);
if ([arrayM containsObject:aClass]) {
NSLog(@"return class = %@", aClass);
return;
}else{
[arrayM addObject:aClass];
}
// 保留原方法 并将新方法的IMP指向原方法
[self exchangeDelegateOfOriginClass:aClass];
}
//- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message
/**交互原类中相关的代理方法*/
- (void)exchangeDelegateOfOriginClass:(Class)cls{
// scrollViewDidScroll
SEL originSel = @selector(userContentController:didReceiveScriptMessage:);
Method originMethod = class_getInstanceMethod(cls, originSel);
origin_userContentControllerDidReceiveScriptMessage = (void*)method_getImplementation(originMethod);
// NSLog(@"%s - %s - %s - %s",@encode(BOOL),@encode(UIWebView),@encode(NSURLRequest),@encode(UIWebViewNavigationType));
// B返回bool值, @表示id类型, :表示方法类型, b表示long long类型, 所以 B(返回值)@:@(第一个参数)@(第二个参数)b(第三个参数)
if (!class_addMethod(cls, originSel, (IMP)exchange_userContentControllerDidReceiveScriptMessage, "v@:@")) {// 没有添加成功, 表示方法已经在原类中存在了
method_setImplementation(originMethod, (IMP)exchange_userContentControllerDidReceiveScriptMessage);
}
}
@end
//
// WKWebView+YUNXINSwizzle.h
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/1.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface WKWebView (YUNXINSwizzle)
@end
NS_ASSUME_NONNULL_END
//
// WKWebView+YUNXINSwizzle.m
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/1.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import "WKWebView+YUNXINSwizzle.h"
#import <objc/runtime.h>
// UIScrollViewDelegate代理方法所有的C方法实现
void (*origin_webviewDecidePolicyForNavigationAction)(id, SEL, WKWebView*, WKNavigationAction*, void (^)(WKNavigationActionPolicy));
void exchange_webviewDecidePolicyForNavigationAction(id self, SEL _cmd, WKWebView *webView, WKNavigationAction *navigationAction, id decisionHandler) {
if (origin_webviewDecidePolicyForNavigationAction) {
origin_webviewDecidePolicyForNavigationAction(self, _cmd, webView, navigationAction, decisionHandler);
}
TraceS(@"=====>>>>> exchange webViewAction");
}
static NSMutableArray *arrayM;
@implementation WKWebView (YUNXINSwizzle)
+ (void)load{
Method originalMethod = class_getInstanceMethod([WKWebView class], @selector(setNavigationDelegate:));
Method swizzledMethod = class_getInstanceMethod([WKWebView class], @selector(hook_setNavigationDelegate:));
method_exchangeImplementations(originalMethod, swizzledMethod);
arrayM = [NSMutableArray array];
}
- (void)hook_setNavigationDelegate:(id<WKNavigationDelegate>)delegate{
[self hook_setNavigationDelegate:delegate];
// 获取delegate实际的类 (每个代理类只能调用一次 否则就会循环引用)
Class aClass = [delegate class];
NSLog(@"delegateClass = %@", aClass);
if ([arrayM containsObject:aClass]) {
NSLog(@"return class = %@", aClass);
return;
}else{
[arrayM addObject:aClass];
}
// 保留原方法 并将新方法的IMP指向原方法
[self exchangeDelegateOfOriginClass:aClass];
}
/**交互原类中相关的代理方法*/
- (void)exchangeDelegateOfOriginClass:(Class)cls{
// scrollViewDidScroll
SEL originSel = @selector(webView:decidePolicyForNavigationAction:decisionHandler:);
Method originMethod = class_getInstanceMethod(cls, originSel);
origin_webviewDecidePolicyForNavigationAction = (void*)method_getImplementation(originMethod);
// NSLog(@"%s - %s - %s - %s",@encode(BOOL),@encode(UIWebView),@encode(NSURLRequest),@encode(UIWebViewNavigationType));
// B返回bool值, @表示id类型, :表示方法类型, b表示long long类型, 所以 B(返回值)@:@(第一个参数)@(第二个参数)b(第三个参数)
if (!class_addMethod(cls, originSel, (IMP)exchange_webviewDecidePolicyForNavigationAction, "v@:@")) {// 没有添加成功, 表示方法已经在原类中存在了
method_setImplementation(originMethod, (IMP)exchange_webviewDecidePolicyForNavigationAction);
}
}
@end
......@@ -14,6 +14,8 @@
#define SameScreenOpenAnswer @"9"
#define SameScreenOperateGiveUp @"10"
#define SameScreenSyncSizeOneWay @"19"
#define SameScreenSyncSize @"0"
#define SameScreenOpenView @"1"
#define SameScreenCloseView @"2"
......
......@@ -7,18 +7,21 @@
//
#import <UIKit/UIKit.h>
#import <WebKit/WebKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface YUNXINSameScreenView : UIView
- (instancetype)initWithFrame:(CGRect)frame drawHexColorStr:(NSString *)drawHexColorStr isManager:(BOOL)isManager;
- (instancetype)initWithFrame:(CGRect)frame webView:(WKWebView *)webView drawHexColorStr:(NSString *)drawHexColorStr isManager:(BOOL)isManager;
- (void)updateViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag;
- (void)reloadCurrentView;
- (void)updateWebViewWidth:(CGFloat)width height:(CGFloat)height;
- (void)updateWebViewOneWayWidth:(CGFloat)width height:(CGFloat)height;
- (void)updateViewWithContentY:(CGFloat)contentY;
- (void)updateWebViewWithWebAction:(NSDictionary *)param;
- (NSDictionary *)getShowDic;
......
......@@ -7,7 +7,6 @@
//
#import "YUNXINSameScreenView.h"
#import <WebKit/WebKit.h>
#import "WKWebViewJavascriptBridge.h"
#import "YUNXINSameScreenManager.h"
#import "YWScrawlView.h"
......@@ -56,18 +55,36 @@ dispatch_async(dispatch_get_main_queue(), block);\
return self;
}
- (instancetype)initWithFrame:(CGRect)frame webView:(WKWebView *)webView drawHexColorStr:(NSString *)drawHexColorStr isManager:(BOOL)isManager
{
self = [super initWithFrame:frame];
if (self) {
self.webView = webView;
self.isManager = isManager;
self.viewFrame = frame;
self.hexStr = drawHexColorStr;
self.currentY = -999.0;
self.couldSend = YES;
[self setupUI];
}
return self;
}
- (void)setupUI
{
[self addSubview:self.webView];
_webView.scrollView.delegate = self;
// _webView.UIDelegate = self;
_webView.userInteractionEnabled = self.isManager;
// WebViewJavascriptBridge
self.webViewBridge = [WKWebViewJavascriptBridge bridgeForWebView:self.webView];
[self.webViewBridge setWebViewDelegate:self];
[self.webViewBridge registerHandler:@"sendJS2Native" handler:^(id data, WVJBResponseCallback responseCallback) {
NSDictionary *dic = data;
[self actionWithDic:dic];
responseCallback(@"");
}];
// self.webViewBridge = [WKWebViewJavascriptBridge bridgeForWebView:self.webView];
// [self.webViewBridge setWebViewDelegate:self];
// [self.webViewBridge registerHandler:@"sendJS2Native" handler:^(id data, WVJBResponseCallback responseCallback) {
// NSDictionary *dic = data;
// [self actionWithDic:dic];
// responseCallback(@"");
// }];
}
- (void)actionWithDic:(NSDictionary *)dic
......@@ -101,6 +118,13 @@ dispatch_async(dispatch_get_main_queue(), block);\
_scrawlView.frame = _webView.frame;
}
- (void)updateWebViewOneWayWidth:(CGFloat)width height:(CGFloat)height
{
_webView.frame = CGRectMake((self.viewFrame.size.width - width) / 2, (self.viewFrame.size.height - height) / 2, width, height);
NSLog(@"=======>>>>>> webviewSize:Width:%f Height:%f", width, height);
_scrawlView.frame = _webView.frame;
}
- (void)updateViewWithContentY:(CGFloat)contentY
{
[_webView.scrollView setContentOffset:CGPointMake(0, contentY) animated:YES];
......@@ -108,7 +132,14 @@ dispatch_async(dispatch_get_main_queue(), block);\
- (void)updateWebViewWithWebAction:(NSDictionary *)param
{
[_webViewBridge callHandler:@"sendNative2JS" data:param];
NSData *data = [NSJSONSerialization dataWithJSONObject:param options:kNilOptions error:nil];
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *jsStr = [NSString stringWithFormat:@"sendNative2JS('%@')",string];
// NSString *jsStr = [NSString stringWithFormat:@"shareClick()"];
[self.webView evaluateJavaScript:jsStr completionHandler:^(id _Nullable result, NSError * _Nullable error) {
TraceS(@"%@----%@",result, error);
}];
// [_webViewBridge callHandler:@"sendNative2JS" data:param];
}
- (NSDictionary *)getShowDic
......@@ -243,8 +274,6 @@ dispatch_async(dispatch_get_main_queue(), block);\
webConfig.userContentController = [WKUserContentController new];
_webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, self.viewFrame.size.width, self.viewFrame.size.height) configuration:webConfig];
_webView.backgroundColor = [UIColor colorWithRed:246.0/255 green:246.0/255 blue:246.0/255 alpha:1.0];
_webView.scrollView.delegate = self;
_webView.UIDelegate = self;
}
return _webView;
}
......
......@@ -7,6 +7,7 @@
//
#import <Foundation/Foundation.h>
#import <WebKit/WebKit.h>
@class NIMSession;
......@@ -57,6 +58,16 @@ NS_ASSUME_NONNULL_BEGIN
/// 收到关闭标注通知
- (void)sameScreenReceiveCloseMarkNotification;
/// 自己操作H5触发事件抄送
/// @param param 触发事件json
- (void)sameScreenOperateH5BySelf:(NSDictionary *)param;
/// 对方操作H5触发事件抄送
/// @param param 触发事件json
- (void)sameScreenOperateH5ByOther:(NSDictionary *)param;
@end
@interface YUNXINSameScreenManager : NSObject
......@@ -86,11 +97,19 @@ NS_ASSUME_NONNULL_BEGIN
- (UIView *)getSameScreenViewWithFrame:(CGRect)frame drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager;
- (UIView *)getSameScreenViewWithFrame:(CGRect)frame webView:(WKWebView *)webView drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager;
/// 更新同屏页面的内容
/// @param webUrl 打开的H5的url
/// @param miniFlag H5的url在小程序中对应的flag
- (void)updateSameScreenViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag;
/// 通知对方同步屏幕大小
- (void)sameScreenSynchronizeViewSize;
/// 单向通知对方同步屏幕大小
- (void)sameScreenSynchronizeViewSizeOneWay;
/// 请求同屏
- (void)requestForSameScreen;
......@@ -132,6 +151,12 @@ NS_ASSUME_NONNULL_BEGIN
- (void)undoCanvas;
/// 透传事件给H5
/// @param param 透出事件json
/// @param needSync 是否需要同步到对端
- (void)sendSameScreenH5ActionParam:(NSDictionary *)param needOthersSync:(BOOL)needSync;
/// 发送自定义通知消息 (忽略)
/// @param param param
/// @param action action
......
......@@ -63,6 +63,16 @@
return webView;
}
- (UIView *)getSameScreenViewWithFrame:(CGRect)frame webView:(WKWebView *)webView drawHexColor:(NSString *)hexColorStr isManager:(BOOL)isManager
{
self.isManager = isManager;
self.viewSize = frame.size;
YUNXINSameScreenView *kwebView = [[YUNXINSameScreenView alloc] initWithFrame:frame webView:webView drawHexColorStr:hexColorStr isManager:isManager];
self.webView = kwebView;
return kwebView;
}
- (void)updateSameScreenViewWithWebUrl:(NSString *)webUrl miniFlag:(NSString *)miniFlag
{
[self.webView updateViewWithWebUrl:webUrl miniFlag:miniFlag];
......@@ -74,6 +84,11 @@
[self sendCustomSysMsgWithParam:@{@"width":@(self.viewSize.width), @"height":@(self.viewSize.height)} action:SameScreenSyncSize];
}
- (void)sameScreenSynchronizeViewSizeOneWay
{
[self sendCustomSysMsgWithParam:@{@"width":@(self.viewSize.width), @"height":@(self.viewSize.height)} action:SameScreenSyncSizeOneWay];
}
- (void)receiveCustomSysMsg:(NSDictionary *)msgContent
{
NSDictionary *attachment = msgContent;
......@@ -105,6 +120,9 @@
[self.webView updateViewWithContentY:[param[@"scrollHeight"] floatValue]];
}else if ([action isEqualToString:SameScreenSyncH5]) {
[_webView updateWebViewWithWebAction:param];
if ([_delegate respondsToSelector:@selector(sameScreenOperateH5ByOther:)]) {
[_delegate sameScreenOperateH5ByOther:param];
}
}else if ([action isEqualToString:SameScreenOperateReq]) {
[self dealWithOperateReq:param];
}else if ([action isEqualToString:SameScreenOperateAnswer]) {
......@@ -129,6 +147,10 @@
[_webView clearCanvas];
}else if ([action isEqualToString:SameScreenUndoPreviousPath]) {
[_webView undoOther:param[@"uid"]];
}else if ([action isEqualToString:SameScreenSyncSizeOneWay]) {
CGFloat remoteUesrWidth = [param[@"width"] floatValue];
CGFloat remoteUesrHeight = [param[@"height"] floatValue];
[self.webView updateWebViewOneWayWidth:remoteUesrWidth height:remoteUesrHeight];
}
}
......@@ -213,6 +235,14 @@
- (void)sendSameScreenH5ActionParam:(NSDictionary *)param needOthersSync:(BOOL)needSync
{
[_webView updateWebViewWithWebAction:param];
if (needSync) {
[self sendCustomSysMsgWithParam:param action:SameScreenSyncH5];
}
}
#pragma mark - sendCustomSysMsg
- (void)sendCustomSysMsgWithParam:(NSDictionary *)param action:(NSString *)action
......@@ -220,6 +250,13 @@
if (action.length <= 0) {
return;
}
if ([action isEqualToString:SameScreenSyncH5]) {
if ([_delegate respondsToSelector:@selector(sameScreenOperateH5BySelf:)]) {
[_delegate sameScreenOperateH5BySelf:param];
}
}
NSDictionary *dict = @{
@"id" : @(99),
@"content" : @{@"param": param, @"action":action},
......
......@@ -68,7 +68,7 @@ dispatch_async(dispatch_get_main_queue(), block);\
for (NSInteger i = 0; i < 4; ++i) {
NSInteger x = i % 2;
NSInteger y = i / 2;
MutiFaceContainerView *sizeView = [[MutiFaceContainerView alloc] initWithFrame:CGRectMake(x * size, y *size, size, size)];
MutiFaceContainerView *sizeView = [[MutiFaceContainerView alloc] initWithFrame:CGRectMake(x * size,kStatusBarHeight+ y *size, size, size)];
sizeView.tag = 100 + i;
[self.view addSubview:sizeView];
}
......
......@@ -164,57 +164,55 @@
- (void)createRoomBtnTouched
{
// NSDictionary *dic = @{@"width":@(SCREEN_WIDTH), @"height":@((SCREEN_HEIGHT - kSafeButtomHeight - 100))};
// [self sendSameScreenMsgWithAction:@"0" param:dic];
// MutiFaceViewController *vc = [[MutiFaceViewController alloc] init];
// vc.roomName = self.textField.text;
// vc.needCreate = YES;
// vc.modalPresentationStyle = UIModalPresentationFullScreen;
// [self presentViewController:vc animated:YES completion:nil];
YUNXINDemoViewController *vc = [[YUNXINDemoViewController alloc] init];
vc.otherUid = @"hzyw79241709669453946";
// vc.otherUid = self.otherUid;
// vc.otherUid = @"hzyw79241709669453946";
vc.otherUid = self.otherUid;
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc animated:YES completion:nil];
}
- (void)joinRoomBtnTouched
{
// [self sendSameScreenMsgWithAction:@"1" param:@{@"url":@"http://192.168.70.182/glw/private.html"}];
// [self.webView show];
// MutiFaceViewController *vc = [[MutiFaceViewController alloc] init];
// vc.roomName = self.textField.text;
// vc.needCreate = NO;
// vc.modalPresentationStyle = UIModalPresentationFullScreen;
// [self presentViewController:vc animated:YES completion:nil];
CHPingAnMsgTypeJoinAttachment *attachment = [[CHPingAnMsgTypeJoinAttachment alloc]init];
attachment.extra = @{@"url":@"",@"time":@""};
attachment.param = @{@"id":@"123456",@"name":@"zhangsan"};
NIMMessage *message = [[NIMMessage alloc] init];
NIMCustomObject *customObject = [[NIMCustomObject alloc] init];
customObject.attachment = attachment;
message.messageObject = customObject;
NIMMessageSetting *setting = [[NIMMessageSetting alloc] init];
setting.historyEnabled = NO;
setting.roamingEnabled = NO;
setting.syncEnabled = NO;
setting.shouldBeCounted = NO;
setting.apnsEnabled = NO;
setting.apnsWithPrefix = NO;
setting.routeEnabled = NO;
setting.teamReceiptEnabled = NO;
setting.persistEnable = NO;
setting.isSessionUpdate = NO;
message.setting = setting;
BOOL sendSuccess = [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:[NIMSession session:self.otherUid type:NIMSessionTypeP2P] error:nil];
if (sendSuccess) {
TraceS(@"发送成功!");
_noticeLabel.text = @"发送成功";
}else {
TraceS(@"发送失败!");
_noticeLabel.text = @"发送失败";
}
MutiFaceViewController *vc = [[MutiFaceViewController alloc] init];
vc.roomName = self.textField.text;
vc.needCreate = NO;
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc animated:YES completion:nil];
// CHPingAnMsgTypeJoinAttachment *attachment = [[CHPingAnMsgTypeJoinAttachment alloc]init];
// attachment.extra = @{@"url":@"",@"time":@""};
// attachment.param = @{@"id":@"123456",@"name":@"zhangsan"};
// NIMMessage *message = [[NIMMessage alloc] init];
// NIMCustomObject *customObject = [[NIMCustomObject alloc] init];
// customObject.attachment = attachment;
// message.messageObject = customObject;
//
// NIMMessageSetting *setting = [[NIMMessageSetting alloc] init];
// setting.historyEnabled = NO;
// setting.roamingEnabled = NO;
// setting.syncEnabled = NO;
// setting.shouldBeCounted = NO;
// setting.apnsEnabled = NO;
// setting.apnsWithPrefix = NO;
// setting.routeEnabled = NO;
// setting.teamReceiptEnabled = NO;
// setting.persistEnable = NO;
// setting.isSessionUpdate = NO;
// message.setting = setting;
//
// BOOL sendSuccess = [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:[NIMSession session:self.otherUid type:NIMSessionTypeP2P] error:nil];
// if (sendSuccess) {
// TraceS(@"发送成功!");
// _noticeLabel.text = @"发送成功";
// }else {
// TraceS(@"发送失败!");
// _noticeLabel.text = @"发送失败";
// }
}
......
//
// POCLoginViewController.h
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/17.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface POCLoginViewController : UIViewController
@end
NS_ASSUME_NONNULL_END
//
// POCLoginViewController.m
// MutiFaceDemo
//
// Created by Xu Lichao on 2020/11/17.
// Copyright © 2020 Yuwei. All rights reserved.
//
#import "POCLoginViewController.h"
#import "CHUIFactory.h"
@interface POCLoginViewController ()
@property (nonatomic, strong) UILabel *keyLabel;
@property (nonatomic, strong) UITextField *keyTextField;
@property (nonatomic, strong) UILabel *accountLabel;
@property (nonatomic, strong) UITextField *accountTextField;
@property (nonatomic, strong) UILabel *tokenLabel;
@property (nonatomic, strong) UITextField *tokenTextField;
@property (nonatomic, strong) UILabel *otherLabel;
@property (nonatomic, strong) UITextField *otherTextField;
@property (nonatomic, strong) UILabel *configLabel;
@property (nonatomic, strong) UITextView *configTextView;
@end
@implementation POCLoginViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.keyLabel];
[self.view addSubview:self.keyTextField];
[self.view addSubview:self.accountLabel];
[self.view addSubview:self.accountTextField];
[self.view addSubview:self.tokenLabel];
[self.view addSubview:self.tokenTextField];
[self.view addSubview:self.otherLabel];
[self.view addSubview:self.otherTextField];
[self.view addSubview:self.configLabel];
[self.view addSubview:self.configTextView];
}
- (UILabel *)getLabelWithText:(NSString *)text frame:(CGRect)frame
{
UILabel *label = [CHUIFactory labelWithTitle:text font:kFont(14) textColor:[UIColor blackColor] frame:frame];
return label;
}
- (UITextField *)getTextFieldWithPlacehold:(NSString *)placeholdStr frame:(CGRect)frame
{
UITextField *tf = [[UITextField alloc] initWithFrame:frame];
tf.placeholder = placeholdStr;
tf.font = kFont(14);
tf.layer.borderWidth = 1;
tf.layer.borderColor = [UIColor blackColor].CGColor;
return tf;
}
#pragma mark - setter/getter
- (UILabel *)keyLabel
{
if (!_keyLabel) {
_keyLabel = [self getLabelWithText:@"NIMKEY" frame:CGRectMake(10, kStatusBarHeight, 100, 30)];
}
return _keyLabel;
}
- (UITextField *)keyTextField
{
if (!_keyTextField) {
_keyTextField = [self getTextFieldWithPlacehold:@"输入key" frame:CGRectMake(120, kStatusBarHeight, SCREEN_WIDTH - 130, 30)];
}
return _keyTextField;
}
- (UILabel *)accountLabel
{
if (!_accountLabel) {
_accountLabel = [self getLabelWithText:@"Account" frame:CGRectMake(10, kStatusBarHeight + 35, 100, 30)];
}
return _accountLabel;
}
- (UITextField *)accountTextField
{
if (!_accountTextField) {
_accountTextField = [self getTextFieldWithPlacehold:@"请输入account" frame:CGRectMake(120, kStatusBarHeight + 35, SCREEN_WIDTH - 130, 30)];
}
return _accountTextField;
}
- (UILabel *)tokenLabel
{
if (!_tokenLabel) {
_tokenLabel = [self getLabelWithText:@"Token" frame:CGRectMake(10, kStatusBarHeight + 70, 100, 30)];
}
return _tokenLabel;
}
- (UITextField *)tokenTextField
{
if (!_tokenTextField) {
_tokenTextField = [self getTextFieldWithPlacehold:@"请输入token" frame:CGRectMake(120, kStatusBarHeight + 70, SCREEN_WIDTH - 130, 30)];
}
return _tokenTextField;
}
- (UILabel *)otherLabel
{
if (!_otherLabel) {
_otherLabel = [self getLabelWithText:@"OtherAccount" frame:CGRectMake(10, kStatusBarHeight + 105, 100, 30)];
}
return _otherLabel;
}
- (UITextField *)otherTextField
{
if (!_otherTextField) {
_otherTextField = [self getTextFieldWithPlacehold:@"请输入对方Account" frame:CGRectMake(120, kStatusBarHeight + 105, SCREEN_WIDTH - 130, 30)];
}
return _otherTextField;
}
- (UILabel *)configLabel
{
if (!_configLabel) {
_configLabel = [self getLabelWithText:@"Config" frame:CGRectMake(10, kStatusBarHeight + 140, 100, 30)];
}
return _configLabel;
}
- (UITextView *)configTextView
{
if (!_configTextView) {
_configTextView = [[UITextView alloc] initWithFrame:CGRectMake(10, kStatusBarHeight + 175, SCREEN_WIDTH - 20, 60)];
_configTextView.font = kFont(14);
_configTextView.layer.borderWidth = 1;
_configTextView.layer.borderColor = [UIColor blackColor].CGColor;
}
return _configTextView;
}
@end
......@@ -51,5 +51,10 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册登录 后发表评论