React Native——ActionSheetIOS
发布时间:2020-12-15 07:31:08 所属栏目:百科 来源:网络整理
导读:在App开发中我们也会遇到这样的需求,那就是分享和弹出多项选择操作。在iOS开发中,ActionSheet提供了这样的功能。而React Native同样封装了该功能,那就是ActionSheetIOS. ActionSheetIOS提供了两个静态方法 1、用于弹出分类菜单 showActionSheetWithOption
在App开发中我们也会遇到这样的需求,那就是分享和弹出多项选择操作。在iOS开发中,ActionSheet提供了这样的功能。而React Native同样封装了该功能,那就是ActionSheetIOS. ActionSheetIOS提供了两个静态方法 1、用于弹出分类菜单showActionSheetWithOptions(options: Object,callback: Function)在iOS设备上显示一个ActionSheet弹出框,其中options参数为一个对象,其属性必须包含以下一项或多项:
2、分享弹出窗。static showShareActionSheetWithOptions(options: Object,failureCallback: Function,successCallback: Function)在iOS设备上显示一个分享弹出框,其中options参数为一个对象,其属性包含以下几项(必须至少有message或url):
注:如果
import React,{ Component } from 'react'; import { AppRegistry,StyleSheet,Text,View,ActionSheetIOS,} from 'react-native'; var kwgkwg=React.createClass({ render() { return ( <View style={styles.container}> <Text onPress={this.tip()}>showActionSheetWithOptions</Text> </View> ); },tip(){ ActionSheetIOS.showActionSheetWithOptions({ options:['拨打电话','发送邮件','发送短信','取消'],cancelButtonIndex:3,destructiveButtonIndex:0,},(buttonIndex)=>{console.log('点击了'+buttonIndex)}); },}); const styles = StyleSheet.create({ container: { flex: 1,justifyContent: 'center',alignItems: 'center',backgroundColor: '#F5FCFF',}); AppRegistry.registerComponent('kwgkwg',() => kwgkwg); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |