ActionSheetIOS
显示 iOS 行动表 原生组件。
¥Displays native to iOS Action Sheet component.
示例
¥Example
参考
¥Reference
方法
¥Methods
showActionSheetWithOptions()
static showActionSheetWithOptions: (
options: ActionSheetIOSOptions,
callback: (buttonIndex: number) => void,
);
显示 iOS 操作表。options
对象必须包含以下一项或多项:
¥Display an iOS action sheet. The options
object must contain one or more of:
-
options
(字符串数组) - 按钮标题列表(必需)¥
options
(array of strings) - a list of button titles (required) -
cancelButtonIndex
(整数) -options
中取消按钮的索引¥
cancelButtonIndex
(int) - index of cancel button inoptions
-
cancelButtonTintColor
(字符串) - color 用于更改取消按钮的文本颜色¥
cancelButtonTintColor
(string) - the color used for the change the text color of the cancel button -
destructiveButtonIndex
(整数或整数数组) -options
中破坏性按钮的索引¥
destructiveButtonIndex
(int or array of ints) - indices of destructive buttons inoptions
-
title
(字符串) - 显示在操作表上方的标题¥
title
(string) - a title to show above the action sheet -
message
(字符串) - 显示在标题下方的消息¥
message
(string) - a message to show below the title -
anchor
(数字) - 操作表应锚定的节点(用于 iPad)¥
anchor
(number) - the node to which the action sheet should be anchored (used for iPad) -
tintColor
(字符串) - color 用于非破坏性按钮标题¥
tintColor
(string) - the color used for non-destructive button titles -
disabledButtonIndices
(数字数组) - 应禁用的按钮索引列表¥
disabledButtonIndices
(array of numbers) - a list of button indices which should be disabled -
userInterfaceStyle
(字符串) - 操作表使用的界面风格,可以设置为light
或dark
,否则将使用默认的系统风格¥
userInterfaceStyle
(string) - the interface style used for the action sheet, can be set tolight
ordark
, otherwise the default system style will be used
'callback' 函数采用一个参数,即所选项目的从零开始的索引。
¥The 'callback' function takes one parameter, the zero-based index of the selected item.
最小的例子:
¥Minimal example:
ActionSheetIOS.showActionSheetWithOptions(
{
options: ['Cancel', 'Remove'],
destructiveButtonIndex: 1,
cancelButtonIndex: 0,
},
buttonIndex => {
if (buttonIndex === 1) {
/* destructive action */
}
},
);
dismissActionSheet()
static dismissActionSheet();
取消显示的最上面的 iOS 操作表,如果不存在操作表,则会显示警告。
¥Dismisses the most upper iOS action sheet presented, if no action sheet is present a warning is displayed.
showShareActionSheetWithOptions()
static showShareActionSheetWithOptions: (
options: ShareActionSheetIOSOptions,
failureCallback: (error: Error) => void,
successCallback: (success: boolean, method: string) => void,
);
显示 iOS 共享表。options
对象应包含 message
和 url
之一或两者,并且还可以包含 subject
或 excludedActivityTypes
:
¥Display the iOS share sheet. The options
object should contain one or both of message
and url
and can additionally have a subject
or excludedActivityTypes
:
-
url
(字符串) - 一个要分享的网址¥
url
(string) - a URL to share -
message
(字符串) - 一条要分享的消息¥
message
(string) - a message to share -
subject
(字符串) - 消息的主题¥
subject
(string) - a subject for the message -
excludedActivityTypes
(数组) - 要从 ActionSheet 中排除的活动¥
excludedActivityTypes
(array) - the activities to exclude from the ActionSheet
注意:如果
url
指向本地文件,或者是 base64 编码的 uri,则它指向的文件将被直接加载和共享。通过这种方式,你可以共享图片、视频、PDF 文件等。如果url
指向远程文件或地址,则它必须符合 RFC 2396 中描述的 URL 格式。例如,没有适当协议 (HTTP/HTTPS) 的 Web URL 将不会被共享。¥Note: If
url
points to a local file, or is a base64-encoded uri, the file it points to will be loaded and shared directly. In this way, you can share images, videos, PDF files, etc. Ifurl
points to a remote file or address it must conform to URL format as described in RFC 2396. For example, a web URL without a proper protocol (HTTP/HTTPS) will not be shared.
'failureCallback' 函数采用一个参数,即一个错误对象。该对象上定义的唯一属性是 string
类型的可选 stack
属性。
¥The 'failureCallback' function takes one parameter, an error object. The only property defined on this object is an optional stack
property of type string
.
'successCallback' 函数有两个参数:
¥The 'successCallback' function takes two parameters:
-
表示成功或失败的布尔值
¥a boolean value signifying success or failure
-
成功时表示共享方法的字符串
¥a string that, in the case of success, indicates the method of sharing