Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
DoraemonKit
提交
9d222d9e
D
DoraemonKit
项目概览
DiDi
/
DoraemonKit
12 个月 前同步成功
通知
166
Star
19623
Fork
3062
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
DoraemonKit
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9d222d9e
编写于
7月 27, 2021
作者:
L
litianhao3615
提交者:
GitHub
7月 27, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #867 from litianhao3615/feature/ios-mc
Modify:[iOS]-一机多控,window查找添加keywindow补偿机制,优化系统手势扩展变量命名
上级
467f8670
f813d774
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
79 addition
and
74 deletion
+79
-74
iOS/DoraemonKit/Src/MultiControl/Function/Event/Capture/DoraemonMCEventCapturer.h
...iControl/Function/Event/Capture/DoraemonMCEventCapturer.h
+16
-7
iOS/DoraemonKit/Src/MultiControl/Function/Event/Capture/DoraemonMCEventCapturer.m
...iControl/Function/Event/Capture/DoraemonMCEventCapturer.m
+50
-47
iOS/DoraemonKit/Src/MultiControl/Function/Serialize/EventInfo/DoraemonMCGustureSerializer.m
...unction/Serialize/EventInfo/DoraemonMCGustureSerializer.m
+4
-4
iOS/DoraemonKit/Src/MultiControl/Function/Serialize/XPath/DoraemonMCXPathSerializer.m
...trol/Function/Serialize/XPath/DoraemonMCXPathSerializer.m
+8
-1
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Home/DoraemonDemoHomeViewController.m
...aemonKitDemo/DemoVC/Home/DoraemonDemoHomeViewController.m
+1
-15
未找到文件。
iOS/DoraemonKit/Src/MultiControl/Function/Event/Capture/DoraemonMCEventCapturer.h
浏览文件 @
9d222d9e
...
...
@@ -43,6 +43,11 @@
+
(
void
)
do_mc_swizzleInstanceMethodWithOriginSel
:(
SEL
)
oriSel
swizzledSel
:(
SEL
)
swiSel
cls
:(
Class
)
cls
;
/// 获取key对应的关联对象的值 自动解包成CGPoint
-
(
CGPoint
)
do_mc_point_value_forkey
:(
const
void
*
_Nonnull
)
key
;
/// 获取key对应的关联对象的值 自动解包成CGRect
-
(
CGRect
)
do_mc_rect_value_forkey
:(
const
void
*
_Nonnull
)
key
;
@end
@interface
UIGestureRecognizer
(
DoraemonMCSupport
)
...
...
@@ -53,14 +58,9 @@
-
(
void
)
do_mc_handleGestureSend
:(
id
)
sender
;
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_temp_p
;
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_temp_location
;
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_host_temp_p
;
/// 主机上 手势的触摸坐标
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_location_at_host
;
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_temp_Vol
;
@end
...
...
@@ -70,6 +70,15 @@
@interface
UIPanGestureRecognizer
(
DoraemonMCSupport
)
/// 主机上 平移手势的偏移距离
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_translation_at_host
;
/// 主机上平移手势的加速度
@property
(
nonatomic
,
assign
)
CGPoint
do_mc_vol_at_host
;
@end
@interface
UILongPressGestureRecognizer
(
DoraemonMCSupport
)
@end
@interface
UIControl
(
DoraemonMCSupport
)
...
...
iOS/DoraemonKit/Src/MultiControl/Function/Event/Capture/DoraemonMCEventCapturer.m
浏览文件 @
9d222d9e
...
...
@@ -60,18 +60,37 @@
});
}
-
(
void
)
setDo_mc_vol_at_host
:(
CGPoint
)
do_mc_vol_at_host
{
objc_setAssociatedObject
(
self
,
@selector
(
do_mc_vol_at_host
),
[
NSValue
valueWithCGPoint
:
do_mc_vol_at_host
],
OBJC_ASSOCIATION_RETAIN
);
}
-
(
CGPoint
)
do_mc_vol_at_host
{
return
[
self
do_mc_point_value_forkey
:
_cmd
];
}
-
(
void
)
setDo_mc_translation_at_host
:(
CGPoint
)
do_mc_translation_at_host
{
objc_setAssociatedObject
(
self
,
@selector
(
do_mc_translation_at_host
),
[
NSValue
valueWithCGPoint
:
do_mc_translation_at_host
],
OBJC_ASSOCIATION_RETAIN
);
}
-
(
CGPoint
)
do_mc_translation_at_host
{
return
[
self
do_mc_point_value_forkey
:
_cmd
];
}
-
(
CGPoint
)
do_mc_translationInView
:(
UIView
*
)
view
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
temp_p
))
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
location_at_host
))
{
return
[
self
do_mc_translationInView
:
view
];
}
return
self
.
do_mc_
temp_p
;
return
self
.
do_mc_
location_at_host
;
}
-
(
CGPoint
)
do_mc_velocityInView
:(
UIView
*
)
view
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
temp_Vol
))
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
vol_at_host
))
{
return
[
self
do_mc_translationInView
:
view
];
}
return
self
.
do_mc_
temp_Vol
;
return
self
.
do_mc_
vol_at_host
;
}
...
...
@@ -107,9 +126,6 @@
@end
@interface
UILongPressGestureRecognizer
(
DoraemonMCSupport
)
@end
@implementation
UILongPressGestureRecognizer
(
DoraemonMCSupport
)
...
...
@@ -123,10 +139,10 @@
}
-
(
CGPoint
)
do_mc_locationInView
:(
UIView
*
)
view
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
temp_location
))
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
location_at_host
))
{
return
[
self
do_mc_locationInView
:
view
];
}
return
self
.
do_mc_
temp_location
;
return
self
.
do_mc_
location_at_host
;
}
...
...
@@ -162,18 +178,15 @@
if
(
!
existed
)
{
[
self
.
do_mc_targetActionPairs
addObject
:[[
DoraemonMCGestureTargetActionPair
alloc
]
initWithTarget
:
target
action
:
action
sender
:
self
]];
}
// if ([NSStringFromClass([target class]) isEqualToString:@"UIInterfaceActionSelectionTrackingController"]) {
// NSLog(@"UIInterfaceActionSelectionTrackingController");
// }else
[
self
do_mc_addTarget
:
target
action
:
action
];
// }
[
self
do_mc_addTarget
:
target
action
:
action
];
}
-
(
CGPoint
)
do_mc_locationInView
:(
UIView
*
)
view
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
temp_location
))
{
if
(
CGPointEqualToPoint
(
CGPointZero
,
self
.
do_mc_
location_at_host
))
{
return
[
self
do_mc_locationInView
:
view
];
}
return
self
.
do_mc_
temp_location
;
return
self
.
do_mc_
location_at_host
;
}
-
(
void
)
do_mc_handleGestureSend
:(
id
)
sender
{
...
...
@@ -188,12 +201,6 @@
if
([
DoraemonMCServer
isOpen
])
{
[
self
do_mc_handleGestureSend
:
sender
];
}
// [self.do_mc_targetActionPairs enumerateObjectsUsingBlock:^(DoraemonMCGestureTargetActionPair * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
// if ([NSStringFromClass([obj.target class]) isEqualToString:@"UIInterfaceActionSelectionTrackingController"]) {
//// NSLog(@"UIInterfaceActionSelectionTrackingController");
// [obj doAction];
// }
// }];
}
...
...
@@ -203,7 +210,7 @@
[
obj
doAction
];
}
}];
self
.
do_mc_
temp_location
=
CGPointZero
;
self
.
do_mc_
location_at_host
=
CGPointZero
;
}
-
(
void
)
do_mc_removeTarget
:(
id
)
target
action
:(
SEL
)
action
{
...
...
@@ -233,32 +240,12 @@
}
-
(
void
)
setDo_mc_
temp_p
:(
CGPoint
)
do_mc_temp_p
{
objc_setAssociatedObject
(
self
,
@selector
(
do_mc_
temp_p
),
[
NSValue
valueWithCGPoint
:
do_mc_temp_p
],
OBJC_ASSOCIATION_RETAIN
);
-
(
void
)
setDo_mc_
location_at_host
:(
CGPoint
)
do_mc_location_at_host
{
objc_setAssociatedObject
(
self
,
@selector
(
do_mc_
location_at_host
),
[
NSValue
valueWithCGPoint
:
do_mc_location_at_host
],
OBJC_ASSOCIATION_RETAIN
);
}
-
(
CGPoint
)
do_mc_temp_p
{
id
value
=
objc_getAssociatedObject
(
self
,
_cmd
);
return
[
value
CGPointValue
];
}
-
(
void
)
setDo_mc_temp_Vol
:(
CGPoint
)
temp_Vol
{
objc_setAssociatedObject
(
self
,
@selector
(
do_mc_temp_Vol
),
[
NSValue
valueWithCGPoint
:
temp_Vol
],
OBJC_ASSOCIATION_RETAIN
);
}
-
(
CGPoint
)
do_mc_temp_Vol
{
id
value
=
objc_getAssociatedObject
(
self
,
_cmd
);
return
[
value
CGPointValue
];
}
-
(
void
)
setDo_mc_temp_location
:(
CGPoint
)
do_mc_temp_location
{
objc_setAssociatedObject
(
self
,
@selector
(
do_mc_temp_location
),
[
NSValue
valueWithCGPoint
:
do_mc_temp_location
],
OBJC_ASSOCIATION_RETAIN
);
}
-
(
CGPoint
)
do_mc_temp_location
{
id
value
=
objc_getAssociatedObject
(
self
,
_cmd
);
return
[
value
CGPointValue
];
-
(
CGPoint
)
do_mc_location_at_host
{
return
[
self
do_mc_point_value_forkey
:
_cmd
];
}
-
(
void
)
setValue
:(
id
)
value
forUndefinedKey
:(
NSString
*
)
key
{}
...
...
@@ -454,6 +441,22 @@
-
(
void
)
setValue
:(
id
)
value
forUndefinedKey
:(
NSString
*
)
key
{}
-
(
CGPoint
)
do_mc_point_value_forkey
:(
const
void
*
_Nonnull
)
key
{
NSValue
*
value
=
objc_getAssociatedObject
(
self
,
key
);
if
(
!
[
value
isKindOfClass
:[
NSValue
class
]])
{
return
CGPointZero
;
}
return
[
value
CGPointValue
];
}
-
(
CGRect
)
do_mc_rect_value_forkey
:(
const
void
*
_Nonnull
)
key
{
NSValue
*
value
=
objc_getAssociatedObject
(
self
,
key
);
if
(
!
[
value
isKindOfClass
:[
NSValue
class
]])
{
return
CGRectZero
;
}
return
[
value
CGRectValue
];;
}
@end
iOS/DoraemonKit/Src/MultiControl/Function/Serialize/EventInfo/DoraemonMCGustureSerializer.m
浏览文件 @
9d222d9e
...
...
@@ -88,15 +88,15 @@
CGPoint
point
=
CGPointMake
([
data
[
@"pointX"
]
floatValue
]
,
[
data
[
@"pointY"
]
floatValue
]
);
pan
.
view
.
center
=
CGPointMake
(
point
.
x
,
point
.
y
);
if
(
pan
.
state
==
UIGestureRecognizerStateEnded
||
pan
.
state
==
UIGestureRecognizerStateCancelled
)
{
pan
.
do_mc_t
emp_p
=
CGPointZero
;
pan
.
do_mc_t
ranslation_at_host
=
CGPointZero
;
}
else
{
pan
.
do_mc_t
emp_p
=
translation
;
pan
.
do_mc_
temp_Vol
=
volP
;
pan
.
do_mc_t
ranslation_at_host
=
translation
;
pan
.
do_mc_
vol_at_host
=
volP
;
}
}
CGPoint
locationP
=
CGPointMake
([
eventInfo
[
@"lp"
][
@"x"
]
doubleValue
],
[
eventInfo
[
@"lp"
][
@"y"
]
doubleValue
]);
gusture
.
do_mc_
temp_location
=
locationP
;
gusture
.
do_mc_
location_at_host
=
locationP
;
gusture
.
state
=
[
eventInfo
[
@"state"
]
intValue
];
NSDictionary
*
pps
=
eventInfo
[
@"pps"
];
...
...
iOS/DoraemonKit/Src/MultiControl/Function/Serialize/XPath/DoraemonMCXPathSerializer.m
浏览文件 @
9d222d9e
...
...
@@ -7,6 +7,7 @@
#import "DoraemonMCXPathSerializer.h"
static
NSUInteger
const
kDoraemonMCXPathUseKeyWindowIndex
=
99999
;
@interface
DoraemonMCXPathSerializer
()
// 如果isOneCell为true , 这个字段有值 列表容器的XPath 例如 UITableView , UICollectionView
...
...
@@ -67,7 +68,10 @@
self
.
vcCls
=
[
self
.
class
ownerVCWithView
:
view
];
self
.
windowIndex
=
[[[
UIApplication
sharedApplication
]
windows
]
indexOfObject
:
currentWindow
];
if
(
self
.
windowIndex
==
NSNotFound
&&
[
UIApplication
sharedApplication
].
keyWindow
==
currentWindow
)
{
self
.
windowIndex
=
kDoraemonMCXPathUseKeyWindowIndex
;
}
NSMutableArray
<
DoraemonMCXPathNode
*>
*
currentPathNodeList
=
[
NSMutableArray
array
];
UIView
*
currentV
=
view
;
...
...
@@ -223,6 +227,9 @@
if
([
UIApplication
sharedApplication
].
windows
.
count
>
self
.
windowIndex
)
{
rootWidow
=
[[
UIApplication
sharedApplication
].
windows
objectAtIndex
:
self
.
windowIndex
];
}
if
(
kDoraemonMCXPathUseKeyWindowIndex
==
self
.
windowIndex
)
{
rootWidow
=
[
UIApplication
sharedApplication
].
keyWindow
;
}
if
(
rootWidow
==
nil
)
{
return
nil
;
...
...
iOS/DoraemonKitDemo/DoraemonKitDemo/DemoVC/Home/DoraemonDemoHomeViewController.m
浏览文件 @
9d222d9e
...
...
@@ -78,9 +78,7 @@
txt
=
DoraemonDemoLocalizedString
(
@"通用测试Demo"
);
}
else
if
(
row
==
8
){
txt
=
DoraemonDemoLocalizedString
(
@"内存泄漏测试"
);
}
else
if
(
row
==
9
){
txt
=
DoraemonDemoLocalizedString
(
@"test alert view"
);
}
else
if
(
row
==
10
){
}
else
if
(
row
==
9
){
txt
=
DoraemonDemoLocalizedString
(
@"一机多控制测试"
);
}
cell
.
textLabel
.
text
=
txt
;
...
...
@@ -109,18 +107,6 @@
}
else
if
(
row
==
8
){
vc
=
[[
DoraemonDemoMemoryLeakViewController
alloc
]
init
];
}
else
if
(
row
==
9
){
UIAlertController
*
alert
=
[
UIAlertController
alertControllerWithTitle
:
@"alert"
message
:
@"alert message"
preferredStyle
:
UIAlertControllerStyleAlert
];
UIAlertAction
*
action
=
[
UIAlertAction
actionWithTitle
:
@"确定"
style
:
UIAlertActionStyleDefault
handler
:^
(
UIAlertAction
*
_Nonnull
action
)
{
NSLog
(
@"confirm"
);
}];
UIAlertAction
*
cancelAction
=
[
UIAlertAction
actionWithTitle
:
@"取消"
style
:
UIAlertActionStyleDefault
handler
:^
(
UIAlertAction
*
_Nonnull
action
)
{
NSLog
(
@"cancel"
);
}];
[
alert
addAction
:
action
];
[
alert
addAction
:
cancelAction
];
[
self
.
navigationController
presentViewController
:
alert
animated
:
YES
completion
:
nil
];
}
else
if
(
row
==
10
){
vc
=
[[
DoraemonDemoMultiControlViewController
alloc
]
init
];
}
if
(
vc
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录