Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 98874036
由
cgx
编写于
2022-08-25 10:33:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
引入KVOController
1 个父辈
1a253ce3
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
38 行增加
和
30 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Basement/DSConfig/PrefixHeader.pch
DreamSleep/DreamSleep/Basement/H5/DsWebController.m
DreamSleep/DreamSleep/Class/AISleepModule/SleepCoach/Controller/AISleepCoachController.m
DreamSleep/Podfile
DreamSleep/Podfile.lock
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
9887403
...
@@ -2564,7 +2564,7 @@
...
@@ -2564,7 +2564,7 @@
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/QQ",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/QQ",
);
);
MARKETING_VERSION = 2.
2.0
;
MARKETING_VERSION = 2.
0.1
;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
OTHER_LDFLAGS = (
"$(inherited)",
"$(inherited)",
...
@@ -2644,7 +2644,7 @@
...
@@ -2644,7 +2644,7 @@
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/QQ",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/QQ",
);
);
MARKETING_VERSION = 2.
2.0
;
MARKETING_VERSION = 2.
0.1
;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
OTHER_LDFLAGS = (
"$(inherited)",
"$(inherited)",
...
@@ -2786,7 +2786,7 @@
...
@@ -2786,7 +2786,7 @@
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/WeChat/WechatSDK",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/QQ",
"$(PROJECT_DIR)/DreamSleep/Vendors/UMSDK/share/share_ios_6.10.5/SocialLibraries/QQ",
);
);
MARKETING_VERSION = 2.
2.0
;
MARKETING_VERSION = 2.
0.1
;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
OTHER_LDFLAGS = (
"$(inherited)",
"$(inherited)",
...
...
DreamSleep/DreamSleep/Basement/DSConfig/PrefixHeader.pch
查看文件 @
9887403
...
@@ -47,4 +47,6 @@
...
@@ -47,4 +47,6 @@
#import "NSObject+AutoCancelRequest.h"
#import "NSObject+AutoCancelRequest.h"
#import <KVOController/KVOController.h>
#endif /* PrefixHeader_pch */
#endif /* PrefixHeader_pch */
DreamSleep/DreamSleep/Basement/H5/DsWebController.m
查看文件 @
9887403
...
@@ -29,7 +29,9 @@
...
@@ -29,7 +29,9 @@
@property
(
assign
,
nonatomic
)
BOOL
webViewLoadTitle
;
@property
(
assign
,
nonatomic
)
BOOL
webViewLoadTitle
;
@end
@end
@implementation
DsWebController
@implementation
DsWebController
{
FBKVOController
*
_fbKVO
;
}
-
(
instancetype
)
initWithTitle
:
(
NSString
*
)
title
link
:
(
NSString
*
)
link
{
-
(
instancetype
)
initWithTitle
:
(
NSString
*
)
title
link
:
(
NSString
*
)
link
{
if
(
self
=
[
super
init
])
{
if
(
self
=
[
super
init
])
{
...
@@ -90,7 +92,6 @@
...
@@ -90,7 +92,6 @@
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
[
self
.
webView
.
configuration
.
userContentController
removeScriptMessageHandlerForName
:
@"AppModel"
];
[
self
.
webView
.
configuration
.
userContentController
removeScriptMessageHandlerForName
:
@"AppModel"
];
[
self
.
webView
removeObserver
:
self
forKeyPath
:
@"estimatedProgress"
];
}
}
-
(
void
)
closeCurrentPage
{
-
(
void
)
closeCurrentPage
{
...
@@ -99,16 +100,6 @@
...
@@ -99,16 +100,6 @@
}
}
}
}
#pragma mark - WKWebView的监听方法
-
(
void
)
observeValueForKeyPath
:
(
NSString
*
)
keyPath
ofObject
:
(
id
)
object
change
:
(
NSDictionary
<
NSKeyValueChangeKey
,
id
>
*
)
change
context
:
(
void
*
)
context
{
if
([
keyPath
isEqualToString
:
@"estimatedProgress"
])
{
[
self
.
progressView
setProgress
:
self
.
webView
.
estimatedProgress
animated
:
YES
];
self
.
progressView
.
hidden
=
self
.
progressView
.
progress
==
1
;
}
else
{
[
super
observeValueForKeyPath
:
keyPath
ofObject
:
object
change
:
change
context
:
context
];
}
}
#pragma mark - WKNavigationDelegate
#pragma mark - WKNavigationDelegate
-
(
void
)
webView
:
(
WKWebView
*
)
webView
decidePolicyForNavigationAction
:
(
nonnull
WKNavigationAction
*
)
navigationAction
decisionHandler
:
(
nonnull
void
(
^
)(
WKNavigationActionPolicy
))
decisionHandler
{
-
(
void
)
webView
:
(
WKWebView
*
)
webView
decidePolicyForNavigationAction
:
(
nonnull
WKNavigationAction
*
)
navigationAction
decisionHandler
:
(
nonnull
void
(
^
)(
WKNavigationActionPolicy
))
decisionHandler
{
DSLog
(
@"通用H5页面入口->跳转链接:%@"
,
navigationAction
.
request
.
URL
.
absoluteString
);
DSLog
(
@"通用H5页面入口->跳转链接:%@"
,
navigationAction
.
request
.
URL
.
absoluteString
);
...
@@ -239,10 +230,20 @@
...
@@ -239,10 +230,20 @@
_webView
.
hidden
=
YES
;
_webView
.
hidden
=
YES
;
_webView
.
scrollView
.
bounces
=
NO
;
_webView
.
scrollView
.
bounces
=
NO
;
_webView
.
scrollView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
_webView
.
scrollView
.
contentInsetAdjustmentBehavior
=
UIScrollViewContentInsetAdjustmentNever
;
[
_webView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
NSMutableURLRequest
*
request
=
[[
NSMutableURLRequest
alloc
]
initWithURL
:
self
.
linkUrl
cachePolicy
:
NSURLRequestUseProtocolCachePolicy
timeoutInterval
:
10
.
0
];
NSMutableURLRequest
*
request
=
[[
NSMutableURLRequest
alloc
]
initWithURL
:
self
.
linkUrl
cachePolicy
:
NSURLRequestUseProtocolCachePolicy
timeoutInterval
:
10
.
0
];
self
.
request
=
request
;
self
.
request
=
request
;
[
_webView
loadRequest
:
self
.
request
];
[
_webView
loadRequest
:
self
.
request
];
WS
(
weaksSelf
);
_fbKVO
=
[
FBKVOController
controllerWithObserver
:
self
];
[
_fbKVO
observe
:
_webView
keyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
block
:^
(
id
_Nullable
observer
,
id
_Nonnull
object
,
NSDictionary
<
NSString
*
,
id
>
*
_Nonnull
change
)
{
NSString
*
changeKeyPath
=
change
[
FBKVONotificationKeyPathKey
];
if
([
changeKeyPath
isEqualToString
:
@"estimatedProgress"
])
{
[
weaksSelf
.
progressView
setProgress
:
weaksSelf
.
webView
.
estimatedProgress
animated
:
YES
];
weaksSelf
.
progressView
.
hidden
=
weaksSelf
.
progressView
.
progress
==
1
;
}
}];
}
}
return
_webView
;
return
_webView
;
}
}
...
...
DreamSleep/DreamSleep/Class/AISleepModule/SleepCoach/Controller/AISleepCoachController.m
查看文件 @
9887403
...
@@ -24,7 +24,9 @@
...
@@ -24,7 +24,9 @@
@property
(
assign
,
nonatomic
)
BOOL
webViewLoadTitle
;
@property
(
assign
,
nonatomic
)
BOOL
webViewLoadTitle
;
@end
@end
@implementation
AISleepCoachController
@implementation
AISleepCoachController
{
FBKVOController
*
_fbKVO
;
}
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
...
@@ -63,7 +65,6 @@
...
@@ -63,7 +65,6 @@
-
(
void
)
dealloc
{
-
(
void
)
dealloc
{
[
self
.
aiWebView
.
configuration
.
userContentController
removeScriptMessageHandlerForName
:
@"AppModel"
];
[
self
.
aiWebView
.
configuration
.
userContentController
removeScriptMessageHandlerForName
:
@"AppModel"
];
[
self
.
aiWebView
removeObserver
:
self
forKeyPath
:
@"estimatedProgress"
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
NeedUpdateAICoach
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
NeedUpdateAICoach
object
:
nil
];
}
}
...
@@ -80,16 +81,6 @@
...
@@ -80,16 +81,6 @@
[
self
.
aiWebView
reload
];
[
self
.
aiWebView
reload
];
}
}
#pragma mark - WKWebView的监听方法
-
(
void
)
observeValueForKeyPath
:
(
NSString
*
)
keyPath
ofObject
:
(
id
)
object
change
:
(
NSDictionary
<
NSKeyValueChangeKey
,
id
>
*
)
change
context
:
(
void
*
)
context
{
if
([
keyPath
isEqualToString
:
@"estimatedProgress"
])
{
self
.
progressView
.
progress
=
self
.
aiWebView
.
estimatedProgress
;
if
(
self
.
progressView
.
progress
==
1
)
{
self
.
progressView
.
hidden
=
YES
;
}
}
else
{
[
super
observeValueForKeyPath
:
keyPath
ofObject
:
object
change
:
change
context
:
context
];
}
}
#pragma mark - WKNavigationDelegate
#pragma mark - WKNavigationDelegate
-
(
void
)
webView
:
(
WKWebView
*
)
webView
decidePolicyForNavigationAction
:
(
nonnull
WKNavigationAction
*
)
navigationAction
decisionHandler
:
(
nonnull
void
(
^
)(
WKNavigationActionPolicy
))
decisionHandler
{
-
(
void
)
webView
:
(
WKWebView
*
)
webView
decidePolicyForNavigationAction
:
(
nonnull
WKNavigationAction
*
)
navigationAction
decisionHandler
:
(
nonnull
void
(
^
)(
WKNavigationActionPolicy
))
decisionHandler
{
NSString
*
url
=
navigationAction
.
request
.
URL
.
absoluteString
;
NSString
*
url
=
navigationAction
.
request
.
URL
.
absoluteString
;
...
@@ -263,7 +254,6 @@
...
@@ -263,7 +254,6 @@
_aiWebView
.
backgroundColor
=
DSWhite
;
_aiWebView
.
backgroundColor
=
DSWhite
;
_aiWebView
.
hidden
=
YES
;
_aiWebView
.
hidden
=
YES
;
_aiWebView
.
scrollView
.
bounces
=
NO
;
_aiWebView
.
scrollView
.
bounces
=
NO
;
[
_aiWebView
addObserver
:
self
forKeyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
context
:
nil
];
_aiWebView
.
navigationDelegate
=
self
;
_aiWebView
.
navigationDelegate
=
self
;
_aiWebView
.
scrollView
.
showsVerticalScrollIndicator
=
NO
;
_aiWebView
.
scrollView
.
showsVerticalScrollIndicator
=
NO
;
_aiWebView
.
scrollView
.
showsHorizontalScrollIndicator
=
NO
;
_aiWebView
.
scrollView
.
showsHorizontalScrollIndicator
=
NO
;
...
@@ -275,6 +265,16 @@
...
@@ -275,6 +265,16 @@
NSDictionary
*
dict
=
[
NSHTTPCookie
requestHeaderFieldsWithCookies
:
cookies
];
NSDictionary
*
dict
=
[
NSHTTPCookie
requestHeaderFieldsWithCookies
:
cookies
];
self
.
request
.
allHTTPHeaderFields
=
dict
;
self
.
request
.
allHTTPHeaderFields
=
dict
;
[
_aiWebView
loadRequest
:
self
.
request
];
[
_aiWebView
loadRequest
:
self
.
request
];
WS
(
weaksSelf
);
_fbKVO
=
[
FBKVOController
controllerWithObserver
:
self
];
[
_fbKVO
observe
:
_aiWebView
keyPath
:
@"estimatedProgress"
options
:
NSKeyValueObservingOptionNew
block
:^
(
id
_Nullable
observer
,
id
_Nonnull
object
,
NSDictionary
<
NSString
*
,
id
>
*
_Nonnull
change
)
{
NSString
*
changeKeyPath
=
change
[
FBKVONotificationKeyPathKey
];
if
([
changeKeyPath
isEqualToString
:
@"estimatedProgress"
])
{
weaksSelf
.
progressView
.
progress
=
weaksSelf
.
aiWebView
.
estimatedProgress
;
if
(
weaksSelf
.
progressView
.
progress
==
1
)
{
weaksSelf
.
progressView
.
hidden
=
YES
;
}
}
}];
}
}
return
_aiWebView
;
return
_aiWebView
;
}
}
...
...
DreamSleep/Podfile
查看文件 @
9887403
...
@@ -16,6 +16,7 @@ target 'DreamSleep' do
...
@@ -16,6 +16,7 @@ target 'DreamSleep' do
pod
'IQKeyboardManager'
,
'~> 6.5.10'
pod
'IQKeyboardManager'
,
'~> 6.5.10'
pod
'KTVHTTPCache'
,
'~> 2.0.1'
pod
'KTVHTTPCache'
,
'~> 2.0.1'
pod
'TZImagePickerController'
,
'~> 3.8.3'
pod
'TZImagePickerController'
,
'~> 3.8.3'
pod
'KVOController'
,
'~> 1.2.0'
end
end
# AFNetworking (4.0.1)
# AFNetworking (4.0.1)
...
...
DreamSleep/Podfile.lock
查看文件 @
9887403
...
@@ -36,6 +36,7 @@ PODS:
...
@@ -36,6 +36,7 @@ PODS:
- CocoaAsyncSocket
- CocoaAsyncSocket
- KTVHTTPCache (2.0.1):
- KTVHTTPCache (2.0.1):
- KTVCocoaHTTPServer
- KTVCocoaHTTPServer
- KVOController (1.2.0)
- lottie-ios (2.5.3)
- lottie-ios (2.5.3)
- Masonry (1.1.0)
- Masonry (1.1.0)
- MBProgressHUD (1.2.0)
- MBProgressHUD (1.2.0)
...
@@ -64,6 +65,7 @@ DEPENDENCIES:
...
@@ -64,6 +65,7 @@ DEPENDENCIES:
- FreeStreamer (~> 4.0.0)
- FreeStreamer (~> 4.0.0)
- IQKeyboardManager (~> 6.5.10)
- IQKeyboardManager (~> 6.5.10)
- KTVHTTPCache (~> 2.0.1)
- KTVHTTPCache (~> 2.0.1)
- KVOController (~> 1.2.0)
- lottie-ios (~> 2.5.3)
- lottie-ios (~> 2.5.3)
- Masonry (~> 1.1.0)
- Masonry (~> 1.1.0)
- MBProgressHUD (~> 1.2.0)
- MBProgressHUD (~> 1.2.0)
...
@@ -83,6 +85,7 @@ SPEC REPOS:
...
@@ -83,6 +85,7 @@ SPEC REPOS:
- IQKeyboardManager
- IQKeyboardManager
- KTVCocoaHTTPServer
- KTVCocoaHTTPServer
- KTVHTTPCache
- KTVHTTPCache
- KVOController
- lottie-ios
- lottie-ios
- Masonry
- Masonry
- MBProgressHUD
- MBProgressHUD
...
@@ -103,6 +106,7 @@ SPEC CHECKSUMS:
...
@@ -103,6 +106,7 @@ SPEC CHECKSUMS:
IQKeyboardManager: 45a1fa55c1a5b02c61ac0fd7fd5b62bb4ad20d97
IQKeyboardManager: 45a1fa55c1a5b02c61ac0fd7fd5b62bb4ad20d97
KTVCocoaHTTPServer: df8d7b861e603ff8037e9b2138aca2563a6b768d
KTVCocoaHTTPServer: df8d7b861e603ff8037e9b2138aca2563a6b768d
KTVHTTPCache: 588c3eb16f6bd1e6fde1e230dabfb7bd4e490a4d
KTVHTTPCache: 588c3eb16f6bd1e6fde1e230dabfb7bd4e490a4d
KVOController: d72ace34afea42468329623b3379ab3cd1d286b6
lottie-ios: a50d5c0160425cd4b01b852bb9578963e6d92d31
lottie-ios: a50d5c0160425cd4b01b852bb9578963e6d92d31
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406
MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406
...
@@ -114,6 +118,6 @@ SPEC CHECKSUMS:
...
@@ -114,6 +118,6 @@ SPEC CHECKSUMS:
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
YYWebImage: 5f7f36aee2ae293f016d418c7d6ba05c4863e928
YYWebImage: 5f7f36aee2ae293f016d418c7d6ba05c4863e928
PODFILE CHECKSUM:
c1c1abe6284d1810dd534fffee52305ff0a63f06
PODFILE CHECKSUM:
319229d796748f474e0ae37b0e38d522e1eeac48
COCOAPODS: 1.11.3
COCOAPODS: 1.11.3
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论