Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
1364d280
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6018
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
1364d280
编写于
7月 29, 2024
作者:
DCloud_iOS_XHY
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iOS 补齐 get-native-view uts 插件实现
上级
944fc893
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
37 addition
and
29 deletion
+37
-29
uni_modules/uts-get-native-view/utssdk/app-ios/DCGetElementByID.swift
...uts-get-native-view/utssdk/app-ios/DCGetElementByID.swift
+0
-22
uni_modules/uts-get-native-view/utssdk/app-ios/index.uts
uni_modules/uts-get-native-view/utssdk/app-ios/index.uts
+37
-7
未找到文件。
uni_modules/uts-get-native-view/utssdk/app-ios/DCGetElementByID.swift
已删除
100644 → 0
浏览文件 @
944fc893
//
// DCUni.swift
// DCGetElementByID
//
// Created by DCloud-iOS-XHY on 2024/7/8.
//
import
DCloudUniappRuntime
public
class
DCGetElementByID
{
/// 返回一个匹配特定 ID 的元素, 如果不存在,返回 null 规则同 https://doc.dcloud.net.cn/uni-app-x/api/get-element.html#getelementbyid
public
static
func
dcGetElementById
(
_
id
:
String
)
->
UniElement
?
{
let
appManager
=
UniSDKEngine
.
self
.
getAppManager
()
if
let
app
=
appManager
.
getCurretApp
(),
let
pageManager
=
app
.
pageManager
as?
UniPageManagerImpl
,
let
page
=
pageManager
.
getTopPage
(),
let
domManager
=
page
.
document
as?
UniDomManager
{
return
domManager
.
getElementById
(
id
)
}
return
nil
}
}
uni_modules/uts-get-native-view/utssdk/app-ios/index.uts
浏览文件 @
1364d280
import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView } from "../interface";
import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView
, CheckWebViewNativeView, CheckInputNativeView, CheckTextareaNativeView, CheckViewNativeView
} from "../interface";
import { WKWebView } from 'WebKit';
import { WKWebView } from 'WebKit';
import { UIView, UITextField, UITextView } from "UIKit"
export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
// const element = uni.getElementById(elementId)
const element = uni.getElementById(elementId)
const element = DCGetElementByID.dcGetElementById(elementId)
const view = element?.getIOSView();
const view = element?.getIOSView();
if (view != null && view instanceof WKWebView) {
if (view != null && view instanceof WKWebView) {
return (view! as WKWebView).canGoBack;
return (view! as WKWebView).canGoBack;
...
@@ -12,8 +12,7 @@ export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string)
...
@@ -12,8 +12,7 @@ export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string)
}
}
export const canWebViewGoForward : CanWebViewGoForward = function (elementId : string) : boolean {
export const canWebViewGoForward : CanWebViewGoForward = function (elementId : string) : boolean {
// const element = uni.getElementById(elementId)
const element = uni.getElementById(elementId)
const element = DCGetElementByID.dcGetElementById(elementId)
const view = element?.getIOSView();
const view = element?.getIOSView();
if (view != null && view instanceof WKWebView) {
if (view != null && view instanceof WKWebView) {
return (view! as WKWebView).canGoForward;
return (view! as WKWebView).canGoForward;
...
@@ -22,11 +21,42 @@ export const canWebViewGoForward : CanWebViewGoForward = function (elementId : s
...
@@ -22,11 +21,42 @@ export const canWebViewGoForward : CanWebViewGoForward = function (elementId : s
}
}
export const hasNativeView : HasNativeView = function (elementId : string) : boolean {
export const hasNativeView : HasNativeView = function (elementId : string) : boolean {
// const element = uni.getElementById(elementId)
const element = uni.getElementById(elementId)
const element = DCGetElementByID.dcGetElementById(elementId)
const view = element?.getIOSView();
const view = element?.getIOSView();
if (view != null && view instanceof WKWebView) {
if (view != null && view instanceof WKWebView) {
return true;
return true;
}
}
return false;
return false;
}
}
export const checkWebViewNativeView : CheckWebViewNativeView = function (elementId : string) : boolean {
return hasNativeView(elementId)
}
export const checkInputNativeView : CheckInputNativeView = function (elementId : string) : boolean {
const element = uni.getElementById(elementId)
const view = element?.getIOSView();
if (view != null && view instanceof UITextField) {
return true;
}
return false;
}
export const checkTextareaNativeView : CheckTextareaNativeView = function (elementId : string) : boolean {
const element = uni.getElementById(elementId)
const view = element?.getIOSView();
if (view != null && view instanceof UITextView) {
return true;
}
return false;
}
export const checkViewNativeView : CheckViewNativeView = function (elementId : string) : boolean {
const element = uni.getElementById(elementId)
const view = element?.getIOSView();
if (view != null && view instanceof UIView) {
return true;
}
return false;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录