【原】东方耀REACT-NATIVE学习43,ios日期组件 ActionSheetIOS

需求:分享和弹出多项选择操作!在IOS开发中,ActionSheet提供了这样的功能,而React Native同样封装了该功能,那就是ActionSheetIOS

提供了两个静态方法:

static showActionSheetWithOptions(options,callback):

在iOS设备上显示一个ActionSheet弹出框,其中options参数为一个对象,其属性必须包含以下一项或多项:

options(字符串数组) - 一组按钮的标题(必选)

cancelButtonIndex(整型) - 选项中取消按钮所在的位置(索引)

destructiveButtonIndex(整型) - 红色高亮显示的位置(索引)

title(字符串) - 弹出框顶部的标题

message(字符串) - 弹出框顶部标题下方的信息

static showShareActionSheetWithOptions(options,failureCallback,successCallback):

在iOS设备上显示一个分享弹出框,其中options参数为一个对象,其属性必须包含以下一项或多项:

message(字符串) - 要分享的信息

url(字符串) - 要分享的URL地址

注:如果url指向本地文件,或者是一个base64编码的url,则会直接读取并分享相应的文件。你可以用这样的方式来分享图片、视频以及PDF文件等。

source code:
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/

import React, { Component } from ‘react’;
import {
AppRegistry,
StyleSheet,
Text,
View,
ActionSheetIOS,
} from ‘react-native’;

class demo extends Component {

render() {
return (

  <Text style={styles.item} onPress={this.tip} > showActionsHEETwITHoPTIons</Text>
  <Text style={styles.item} onPress={this.share} > showShareActionSheetWithOptions</Text>

  </View>
);

}

tip(){
ActionSheetIOS.showActionSheetWithOptions(
{
options:[‘tel’,’email’,’sms’,’cancel’],
cancelButtonIndex:3,
destructiveButtonIndex:0,
title:’which operation?’,
message:’think carefully’,
},
function(index){
alert(index);

}

);
}

share(){
ActionSheetIOS.showShareActionSheetWithOptions(
{
message:’我的论坛’,
url:’http://www.reactnative.vip
},
function(err){
alert(err);
},
function(suc){
alert(suc);
}
)
}

}

const styles = StyleSheet.create({
container: {
flex: 1,

},
flex:{
flex:1,
},
item:{
marginTop:10,
marginLeft:5,
marginRight:5,
height:30,
borderWidth:1,
padding:6,
borderColor:’#ddd’,

}
});

AppRegistry.registerComponent(‘demo’, () => demo);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值