-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
129 lines (112 loc) · 3.19 KB
/
index.ios.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
NavigatorIOS,
ActionSheetIOS,
TouchableHighlight
} from 'react-native';
import BDMapView from './BDMapView.ios'
import ImagePickerManager from 'NativeModules';
export default class AwesomeProject extends Component {
render() {
return (
<View style={styles.view} >
<BDMapView style={styles.map} />
<TouchableHighlight style={[ styles.center]}
onPress={e=>this.test(e)}
>
<Text>居中摆放</Text>
</TouchableHighlight>
</View>
)
}
test(e){
var options = {
title: '更换头像', // 选择器的标题,可以设置为空来不显示标题
cancelButtonTitle: '取消',
takePhotoButtonTitle: '从相机拍照获取', // 调取摄像头的按钮,可以设置为空使用户不可选择拍照
chooseFromLibraryButtonTitle: '从手机相册选择', // 调取相册的按钮,可以设置为空使用户不可选择相册照片
/*
customButtons: {
'Choose Photo from Facebook': 'fb', // [按钮文字] : [当选择这个按钮时返回的字符串]
},
mediaType: 'photo', // 'photo' or 'video'
videoQuality: 'high', // 'low', 'medium', or 'high'
durationLimit: 10, // video recording max time in seconds
maxWidth: 100, // photos only默认为手机屏幕的宽,高与宽一样,为正方形照片
maxHeight: 100, // photos only*/
allowsEditing: true, // 当用户选择过照片之后是否允许再次编辑图片
};
let ImagePickerManager = require('react-native-image-picker');
ImagePickerManager.showImagePicker(options, (response) => {
if (response.didCancel) {
console.log('User cancelled image picker');
}
else if (response.error) {
console.log('ImagePickerManager Error: ', response.error);
}
else if (response.customButton) {
// 这是当用户选择customButtons自定义的按钮时,才执行
console.log('User tapped custom button: ', response.customButton);
}
else {
// You can display the image using either data:
if (Platform.OS === 'android') {
source = {uri: response.uri, isStatic: true};
} else {
source = {
uri: response.uri.replace('file://', ''),
isStatic: true
};
}
this.setState({
avatarSource: source
});
}
});
}
}
const styles = StyleSheet.create({
view: {
flex: 1,
},
map: {
flex: 1,
},
splitline: {
flexDirection : 'row',
height: 50,
position:'absolute',
left: 50,
top:50,
alignItems: 'center',
justifyContent: 'center',
},
views:{
position: 'absolute',
borderWidth: 5,
borderColor: 'blue',
left: 40,
bottom: 20,
width: 100,
height: 40
},
center:{
alignSelf: 'center'
},
left:{
alignSelf: 'flex-start'
},
right:{
alignSelf: 'flex-end'
}
});
AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);