我在React Native应用程序中遇到WebView问题。如果未指定WebView的高度,则默认为屏幕高度的大约一半(iPhone 6S)。但是,当我在Dimensions
的帮助下设置高度时,它显示正常,但只有原来的一半是交互式的 - 即。只能使用屏幕的上半部分进行滚动。React Native:WebView高度设置不正确
这里是我当前的代码的主要部分:
import React, { Component } from 'react';
import {
...
Dimensions,
...
WebView,
} from 'react-native';
let ScreenHeight = Dimensions.get("window").height;
let ScreenWidth = Dimensions.get("window").width;
class App extends Component {
render() {
return (
<View style={styles.container}>
...
<WebView
source={{uri: 'http://foo.com'}}
style={{height: ScreenHeight, width: ScreenWidth}}
/>
...
</View>
);
}
}
...
const styles = StyleSheet.create({
container: {
backgroundColor: '#bbb',
flex: 1,
},
...
});
AppRegistry.registerComponent('myApp',() => App);
我期待着可以提供:)