我在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);
我期待着可以提供:)