Cha*_*had 11 javascript ios reactjs react-native expo
我正在将TouchableOpacity与嵌套在其中的图像进行映射.它适用于Android,但在iOS上,图像是不可见的.仍然有一个75x75可触摸的不透明度,我可以点击但图像在弹出的模式中是不可见的,一般来说.
这是如何运作的?我正在使用Expo SDK FileSystem来获取每个图像的路径.
例如:file://path/to/container/progress/myfilehash.jpg
我将其推送到我的状态并将其映射到组件中.require()函数对我这样做的方式不起作用.我认为这完全是渲染的问题.
地图代码:
{this.state.images.map((val, key) => (
<TouchableOpacity
key={key}
onPress={() => this.setState({active: val, modal: true})}
>
<Image
style={{width: 75, height: 75}}
source={{isStatic: true, uri: val}}
/>
</TouchableOpacity>
))}
Run Code Online (Sandbox Code Playgroud)
莫代尔:
<Container style={Colors.Backdrop}>
<Header style={Colors.Navbar}>
<Left>
<TouchableHighlight
onPress={() => {
this.setState({modal: false})
}}>
<Icon
name="arrow-back"
style={{color: 'white'}}
/>
</TouchableHighlight>
</Left>
<Body></Body>
<Right>
<TouchableOpacity
onPress={() => {
this._deleteImage(this.state.active);
}}>
<Text
style={[
Colors.ErrorText, {
fontSize: 24,
marginRight: 10
}
]}>×</Text>
</TouchableOpacity>
</Right>
</Header>
<Content>
<View
style={{flex: 1}}
>
<FitImage
source={{uri: this.state.active}}
/>
</View>
</Content>
</Container>
Run Code Online (Sandbox Code Playgroud)
用于获取图像路径的代码.(注意:我尝试不从ios截断"file://",但结果完全相同)
_getAllImagesInDirectory = async() => {
let dir = await FileSystem.readDirectoryAsync(FileSystem.documentDirectory + 'progress');
dir.forEach((val) => {
this.state.images.push(Platform.OS === 'ios' ? FileSystem.documentDirectory.substring(7, FileSystem.documentDirectory.length) : FileSystem.documentDirectory + 'progress/' + val);
});
await this.setState({images: this.state.images, loading: false});
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
313 次 |
| 最近记录: |