> [ActionSheetIOS](http://facebook.github.io/react-native/docs/actionsheetios.html#content)
## 方法
* static showActionSheetWithOptions(options: Object, callback: Function) :顯示上拉菜單
* static showShareActionSheetWithOptions(options: Object, failureCallback: Function, successCallback: Function):顯示分享菜單
## 實例
~~~
'use strict';
var React = require('react-native');
var {
ActionSheetIOS,
StyleSheet,
Text,
View,
} = React;
var BUTTONS = [
'Button Index: 0',
'Button Index: 1',
'Button Index: 2',
'Destruct',
'Cancel',
];
var DESTRUCTIVE_INDEX = 3;
var CANCEL_INDEX = 4;
var ActionSheetExample = React.createClass({
getInitialState() {
return {
clicked: 'none',
};
},
render() {
return (
<View>
<Text onPress={this.showActionSheet} style={style.button}>
Click to show the ActionSheet
</Text>
<Text>
Clicked button at index: "{this.state.clicked}"
</Text>
</View>
);
},
showActionSheet() {
ActionSheetIOS.showActionSheetWithOptions({
options: BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
},
(buttonIndex) => {
this.setState({ clicked: BUTTONS[buttonIndex] });
});
}
});
var ShareActionSheetExample = React.createClass({
getInitialState() {
return {
text: ''
};
},
render() {
return (
<View>
<Text onPress={this.showShareActionSheet} style={style.button}>
Click to show the Share ActionSheet
</Text>
<Text>
{this.state.text}
</Text>
</View>
);
},
showShareActionSheet() {
ActionSheetIOS.showShareActionSheetWithOptions({
url: 'https://code.facebook.com',
},
(error) => {
console.error(error);
},
(success, method) => {
var text;
if (success) {
text = `Shared via ${method}`;
} else {
text = 'You didn\'t share';
}
this.setState({text})
});
}
});
var style = StyleSheet.create({
button: {
marginBottom: 10,
fontWeight: '500',
}
});
exports.title = 'ActionSheetIOS';
exports.description = 'Interface to show iOS\' action sheets';
exports.examples = [
{
title: 'Show Action Sheet',
render(): ReactElement { return <ActionSheetExample />; }
},
{
title: 'Show Share Action Sheet',
render(): ReactElement { return <ShareActionSheetExample />; }
}
];
~~~
## 效果
## 上拉菜單

## 分享菜單

- 前言
- react-native試玩(1)
- react-native試玩(2)
- (3)-窺探開發者選項
- (4)-新建項目
- (5)-小菊花控件
- (6)-日期選擇控件
- (7)-圖片控件
- (8)-列表視圖
- (9)-地圖視圖
- (10)-導航欄
- (11)-模態
- (12)-iOS中導航欄
- (13)-選擇控件
- (14)-iOS中進度欄
- (15)-滾動視圖
- (16)-iOS分段控制控件
- (17)-iOS中的滑動條
- (18)-開關控件
- (19)-分頁欄
- (20)-分頁欄中的元素
- (21)-文本控件
- (22)-文本輸入框
- (23)-觸摸高亮
- (24)-觸摸模糊
- (25)-觸摸無反饋
- (26)-網頁視圖
- (27)-上拉菜單API
- (28)-彈出框API
- (29)-React Native Playground
- (30)-應用狀態API
- (31)-訪問相冊API
- (32)-推送通知API
- (33)-狀態欄API
- (34)-配置Android開發環境
- (35)-react-native-icons插件