类型 函数 库 native.* 返回值 无 修订 版本 2024.3703 关键词 native, showPopup, activity
显示活动弹出窗口,它对应于 iOS 上的 UIActivityViewController
。活动的集合取决于您指定的项目。
native.showPopup( name, options )
字符串. 要显示的弹出窗口的字符串名称。对于活动弹出窗口插件,请使用 "activity"
。
表. 指定弹出窗口参数的表 — 有关详细信息,请参阅下一节。
数组. 默认情况下,将显示所有内置和兼容的活动。您可以通过指定一个字符串数组来排除某个活动,其中每个字符串对应一个活动。有关有效的字符串值,请参阅下面的支持的活动。
表. 仅适用于 iPad。定义 iPad 弹出窗口从中弹出的对象(通常是按钮)的边界。一种方便的模式是传递对象的 contentBounds
属性。
表. 仅适用于 iPad。一个值数组,定义 iPad 弹出窗口箭头可以指向的方向。有效值为 "up"
、"down"
、"left"
、"right"
或 "any"
。默认值为 "any"
。
项目数组是一个数组,其中每个项目是一个包含要执行的活动数据的表。每个项目表都必须包含 type
和 value
属性。
不同的活动支持不同的项目类型。有关支持的活动类型的参考,请参阅 Apple 的文档。
活动插件支持以下活动字符串值,每个值对应于 iOS 上的内置活动。
字符串 | 对应的 iOS 活动 |
---|---|
"UIActivityTypePostToFacebook" |
UIActivityTypePostToFacebook |
"UIActivityTypePostToTwitter" |
UIActivityTypePostToTwitter |
"UIActivityTypePostToWeibo" |
UIActivityTypePostToWeibo |
"UIActivityTypeMessage" |
UIActivityTypeMessage |
"UIActivityTypeMail" |
UIActivityTypeMail |
"UIActivityTypePrint" |
UIActivityTypePrint |
"UIActivityTypeCopyToPasteboard" |
UIActivityTypeCopyToPasteboard |
"UIActivityTypeAssignToContact" |
UIActivityTypeAssignToContact |
"UIActivityTypeSaveToCameraRoll" |
UIActivityTypeSaveToCameraRoll |
"UIActivityTypeAddToReadingList" |
UIActivityTypeAddToReadingList |
"UIActivityTypePostToFlickr" |
UIActivityTypePostToFlickr |
"UIActivityTypePostToVimeo" |
UIActivityTypePostToVimeo |
"UIActivityTypePostToTencentWeibo" |
UIActivityTypePostToTencentWeibo |
"UIActivityTypeAirDrop" |
UIActivityTypeAirDrop |
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local textItems = { { type = "string", value = "Hello World!" }, { type = "string", value = "Good night, and good luck." }, } local options = { items=textItems, listener=popupListener } native.showPopup( "activity", options )
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local urlItems = { { type = "url", value = "http://www.coronalabs.com" }, { type = "url", value = "http://docs.solar2d.cn" }, } local options = { items=urlItems, listener=popupListener } native.showPopup( "activity", options )
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local imageItems = { { type = "image", value = { filename = "world1.jpg", baseDir = system.ResourceDirectory } }, { type = "image", value = { filename = "world2.jpg", baseDir = system.ResourceDirectory } }, } local options = { items=imageItems, listener=popupListener } native.showPopup( "activity", options )
local popupListener = {} function popupListener:popup( event ) print( "(name, type, activity, action):", event.name, event.type, tostring(event.activity), tostring(event.action) ) end local itemsToShare = { { type = "image", value = { filename = "world1.jpg", baseDir = system.ResourceDirectory } }, { type = "url", value = "http://www.coronalabs.com" }, { type = "string", value = "Hello World!" }, } local options = { items=itemsToShare, listener=popupListener } native.showPopup( "activity", options )