【发布时间】:2016-02-12 03:01:06
【问题描述】:
当我专注于一个 TextInput 时,点击另一个 TextInput 字段并没有达到我的预期(将 focus 更改为 TextInput)。
相反,它只是模糊当前的TextInput,需要第二次点击才能聚焦下一个TextInput。
有没有办法做到这一点,或者这是 React Native 当前的缺点?
示例代码:
class MyTest extends Component {
render() {
return (
<ScrollView style={styles.container}>
<View>
<TextInput style={styles.textInput} />
<TextInput style={styles.textInput} />
</View>
</ScrollView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#ddd',
paddingTop: 64
},
textInput: {
backgroundColor: '#fff',
borderColor: '#000',
borderWidth: 1,
height: 46,
paddingLeft: 10
}
});
事实证明,当输入字段位于 ScrollView 中时,它们的行为与我上面描述的一样(您不能只从一个字段点击到另一个字段)。我尝试将 TextInputs 包装在 View 中以解决此问题,但没有奏效。
【问题讨论】:
-
你能在你的帖子中包含一些相关代码吗?
标签: ios react-native