Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
a90f3e0c
Commit
a90f3e0c
authored
Feb 11, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加原生调用h5方法,提供键盘调用,弹出和收起键盘事件
parent
65cb67ef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
YHHomeWebViewController.swift
.../Classes/Modules/Home(首页)/C/YHHomeWebViewController.swift
+20
-0
YHH5WebViewVC.swift
.../Classes/Modules/InteractionH5(与H5交互)/YHH5WebViewVC.swift
+20
-0
No files found.
galaxy/galaxy/Classes/Modules/Home(首页)/C/YHHomeWebViewController.swift
View file @
a90f3e0c
...
...
@@ -303,6 +303,10 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
}
getData
()
updateNetWorkStatusUI
(
needReload
:
false
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
keyboardDidShow(_:)
)
,
name
:
UIResponder
.
keyboardDidShowNotification
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
keyboardDidHide(_:)
)
,
name
:
UIResponder
.
keyboardDidHideNotification
,
object
:
nil
)
}
...
...
@@ -423,6 +427,22 @@ class YHHomeWebViewController: YHBaseViewController, WKUIDelegate, WKNavigationD
previewFileTool
.
openXLSXRemoteFile
(
urlString
:
urlString
,
fileName
:
""
)
}
@objc
func
keyboardDidShow
(
_
notification
:
Notification
)
{
guard
let
userInfo
=
notification
.
userInfo
,
let
keyboardFrame
=
userInfo
[
UIResponder
.
keyboardFrameEndUserInfoKey
]
as?
CGRect
else
{
return
}
let
keyboardHeight
=
keyboardFrame
.
height
// 调用 H5 的 onKeyboardShow 方法,传递高度
let
dict
=
[
"height"
:
"
\(
keyboardHeight
)
"
]
webview
.
callHandler
(
"onKeyboardHeightChanged"
,
arguments
:
[
dict
])
}
@objc
func
keyboardDidHide
(
_
notification
:
Notification
)
{
// 调用 H5 的 onKeyboardHide 方法
let
dict
=
[
"height"
:
"
\(
0
)
"
]
webview
.
callHandler
(
"onKeyboardHeightChanged"
,
arguments
:
[
dict
])
}
// MARK: - WKNavigationDelegate
func
webView
(
_
webView
:
WKWebView
,
didFinish
navigation
:
WKNavigation
!
)
{
// if vcTitle == nil {
...
...
galaxy/galaxy/Classes/Modules/InteractionH5(与H5交互)/YHH5WebViewVC.swift
View file @
a90f3e0c
...
...
@@ -77,6 +77,10 @@ class YHH5WebViewVC: YHBaseViewController, WKUIDelegate, WKNavigationDelegate {
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
setupUI
()
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
keyboardDidShow(_:)
)
,
name
:
UIResponder
.
keyboardDidShowNotification
,
object
:
nil
)
NotificationCenter
.
default
.
addObserver
(
self
,
selector
:
#selector(
keyboardDidHide(_:)
)
,
name
:
UIResponder
.
keyboardDidHideNotification
,
object
:
nil
)
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
...
...
@@ -456,6 +460,22 @@ private extension YHH5WebViewVC {
func
navigationShouldPopOnGesture
()
->
Bool
{
return
!
disableFullScreenGestureFlag
}
@objc
func
keyboardDidShow
(
_
notification
:
Notification
)
{
guard
let
userInfo
=
notification
.
userInfo
,
let
keyboardFrame
=
userInfo
[
UIResponder
.
keyboardFrameEndUserInfoKey
]
as?
CGRect
else
{
return
}
let
keyboardHeight
=
keyboardFrame
.
height
// 调用 H5 的 onKeyboardShow 方法,传递高度
let
dict
=
[
"height"
:
"
\(
keyboardHeight
)
"
]
webview
.
callHandler
(
"onKeyboardHeightChanged"
,
arguments
:
[
dict
])
}
@objc
func
keyboardDidHide
(
_
notification
:
Notification
)
{
// 调用 H5 的 onKeyboardHide 方法
let
dict
=
[
"height"
:
"
\(
0
)
"
]
webview
.
callHandler
(
"onKeyboardHeightChanged"
,
arguments
:
[
dict
])
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment