类型 函数 库 native.* 返回值 无 版本 版本 2024.3703 关键词 native, showPopup, safari, safariView, webView
显示 Safari 视图弹出窗口,该窗口对应于 iOS 9 中引入的 SFSafariViewController
http:// 或 https:// 开头。native.showPopup( name, options )
字符串. 要显示的弹出窗口的字符串名称。对于 Safari 视图插件,请使用 "safariView"。
表. 指定弹出窗口可选属性的表 — 有关详细信息,请参阅下一节。
字符串. 网页的 URL。该 URL 必须以 http:// 或 https:// 开头。
布尔值. 如果为 true,则控制器滑入;否则立即显示。
布尔值. 如果为 true,则在网页可用时自动进入阅读器模式。
监听器. 支持基本 弹出事件 的监听器。对于该事件,event.action (字符串) 可以是以下值之一
"loaded" — 初始加载已完成。"failed" — 表示加载 URL 时出错;Safari 视图保持打开状态。"done" — 表示用户按下“完成”按钮,Safari 视图已关闭。local function safariListener( event )
if ( event.action == "failed" ) then
print( "Error loading the URL" )
elseif ( event.action == "loaded" ) then
print( "Page loaded!" )
elseif ( event.action == "done" ) then
print( "Safari view closed" )
end
end
local popupOptions =
{
url = "https://solar2d.cn",
animated = true,
entersReaderIfAvailable = true,
listener = safariListener
}
-- Check if the Safari View is available
local safariViewAvailable = native.canShowPopup( "safariView" )
if safariViewAvailable then
-- Show the Safari View
native.showPopup( "safariView", popupOptions )
end