Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 412bb9ae
由
cgx
编写于
2022-05-24 18:18:33 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
H5和原生交互调试
1 个父辈
657cfdc4
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
18 行删除
DreamSleep/DreamSleep/Class/AISleepModule/AISleepCoachController.m
DreamSleep/DreamSleep/Class/HomeModule/Course/View/AudioDetailHeaderView.m
DreamSleep/DreamSleep/Class/AISleepModule/AISleepCoachController.m
查看文件 @
412bb9a
...
@@ -93,24 +93,40 @@
...
@@ -93,24 +93,40 @@
decisionHandler
(
WKNavigationActionPolicyAllow
);
decisionHandler
(
WKNavigationActionPolicyAllow
);
}
}
-
(
void
)
userContentController
:
(
WKUserContentController
*
)
userContentController
didReceiveScriptMessage
:
(
WKScriptMessage
*
)
message
{
-
(
void
)
userContentController
:
(
WKUserContentController
*
)
userContentController
didReceiveScriptMessage
:
(
WKScriptMessage
*
)
message
{
if
([
message
.
name
isEqualToString
:
@"click"
])
{
if
([
message
.
name
isEqualToString
:
@"AppModel"
])
{
// NSDictionary *jsData = message.body;
// 打印所传过来的参数,只支持NSNumber, NSString, NSDate, NSArray,
// NSLog(@"%@", message.name);
// NSDictionary, and NSNull类型
//读取js function的字符串
NSDictionary
*
bodyDic
=
message
.
body
;
// NSString *jsFunctionString = jsData[@"result"];
NSLog
(
@"message.body:%@, type:%d"
,
bodyDic
,
[
bodyDic
[
@"type"
]
intValue
]);
// //拼接调用该方法的js字符串(convertDictionaryToJson:方法将NSDictionary转成JSON格式的字符串)
// NSString *jsonString = [NSDictionary convertDictionaryToJson:@{@"test":@"123", @"data":@"666"}];
// NSString *jsCallBack = [NSString stringWithFormat:@"(%@)(%@);", jsFunctionString, jsonString];
// //执行回调
// [self.weWebView evaluateJavaScript:jsCallBack completionHandler:^(id _Nullable result, NSError * _Nullable error) {
// if (error) {
// NSLog(@"err is %@", error.domain);
// }
// }];
}
}
// if ([message.name isEqualToString:@"xxx"]) {
// NSDictionary *jsData = message.body;
// NSLog(@"%@", message.name);
//读取js function的字符串
// NSString *jsFunctionString = jsData[@"result"];
// //拼接调用该方法的js字符串(convertDictionaryToJson:方法将NSDictionary转成JSON格式的字符串)
// NSString *jsonString = [NSDictionary convertDictionaryToJson:@{@"test":@"123", @"data":@"666"}];
// NSString *jsCallBack = [NSString stringWithFormat:@"(%@)(%@);", jsFunctionString, jsonString];
// //执行回调
// [self.weWebView evaluateJavaScript:jsCallBack completionHandler:^(id _Nullable result, NSError * _Nullable error) {
// if (error) {
// NSLog(@"err is %@", error.domain);
// }
// }];
// }
}
-
(
void
)
webView
:
(
WKWebView
*
)
webView
runJavaScriptAlertPanelWithMessage
:
(
NSString
*
)
message
initiatedByFrame
:
(
WKFrameInfo
*
)
frame
completionHandler
:
(
void
(
^
)(
void
))
completionHandler
{
NSLog
(
@"%s"
,
__FUNCTION__
);
UIAlertController
*
alert
=
[
UIAlertController
alertControllerWithTitle
:
@"alert"
message
:
@"JS调用alert"
preferredStyle
:
UIAlertControllerStyleAlert
];
[
alert
addAction
:[
UIAlertAction
actionWithTitle
:
@"确定"
style
:
UIAlertActionStyleDefault
handler
:
^
(
UIAlertAction
*
_Nonnull
action
)
{
completionHandler
();
}]];
[
self
presentViewController
:
alert
animated
:
YES
completion
:
NULL
];
NSLog
(
@"message:%@"
,
message
);
}
}
-
(
WKWebView
*
)
aiWebView
{
-
(
WKWebView
*
)
aiWebView
{
...
@@ -120,7 +136,7 @@
...
@@ -120,7 +136,7 @@
// 实例化对象
// 实例化对象
configuration
.
userContentController
=
[
WKUserContentController
new
];
configuration
.
userContentController
=
[
WKUserContentController
new
];
// 调用JS方法
// 调用JS方法
[
configuration
.
userContentController
addScriptMessageHandler
:
self
name
:
@"A
ndroid.jump2Native(2, 0)
"
];
[
configuration
.
userContentController
addScriptMessageHandler
:
self
name
:
@"A
ppModel
"
];
// 进行偏好设置
// 进行偏好设置
WKPreferences
*
preferences
=
[
WKPreferences
new
];
WKPreferences
*
preferences
=
[
WKPreferences
new
];
...
@@ -132,6 +148,7 @@
...
@@ -132,6 +148,7 @@
_aiWebView
=
[[
WKWebView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
-
kTabBarHeight
)
configuration
:
configuration
];
_aiWebView
=
[[
WKWebView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
kScreenHeight
-
kTabBarHeight
)
configuration
:
configuration
];
_aiWebView
.
backgroundColor
=
DSWhite
;
_aiWebView
.
backgroundColor
=
DSWhite
;
_aiWebView
.
UIDelegate
=
self
;
_aiWebView
.
UIDelegate
=
self
;
[
_aiWebView
debugViewShowBorder
];
_aiWebView
.
scrollView
.
bounces
=
NO
;
_aiWebView
.
scrollView
.
bounces
=
NO
;
[
_aiWebView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
[
_aiWebView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
_aiWebView
.
navigationDelegate
=
self
;
_aiWebView
.
navigationDelegate
=
self
;
...
...
DreamSleep/DreamSleep/Class/HomeModule/Course/View/AudioDetailHeaderView.m
查看文件 @
412bb9a
...
@@ -89,7 +89,6 @@
...
@@ -89,7 +89,6 @@
}
}
[
self
.
bgIV
setCornerRadiusRect
:(
UIRectCornerBottomLeft
|
UIRectCornerBottomRight
)
cornerRadius
:
22
.
0
];
[
self
.
bgIV
setCornerRadiusRect
:(
UIRectCornerBottomLeft
|
UIRectCornerBottomRight
)
cornerRadius
:
22
.
0
];
}
else
{
}
else
{
[
self
.
audioIV
cornerRadius
:
15
.
5
];
self
.
bgIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
self
.
bgIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
self
.
audioIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
self
.
audioIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
3
,
.
5
);
}
}
...
@@ -109,6 +108,7 @@
...
@@ -109,6 +108,7 @@
-
(
UIImageView
*
)
audioIV
{
-
(
UIImageView
*
)
audioIV
{
if
(
!
_audioIV
)
{
if
(
!
_audioIV
)
{
_audioIV
=
[
UIImageView
new
];
_audioIV
=
[
UIImageView
new
];
[
_audioIV
cornerRadius
:
15
.
5
];
}
}
return
_audioIV
;
return
_audioIV
;
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论