简体   繁体   English

TextInput中的文本在ios上的位置不正确

[英]Text in TextInput not in correct position on ios

I have a textInput in a View which is positioned at the center using flex . 我在一个使用flex放置在中心的View有一个textInput the problem is, when you start writing in the textInput , the text gets centered, even though I didn't style it that way... 问题是,当您开始在textInput编写内容时,即使我没有那样设置样式,文本也会居中...

The initial cursor is at the correct position, but as soon as the user starts typing, the text centers. 初始光标位于正确的位置,但是一旦用户开始键入,文本就会居中。

What's weird is that this issue is only with ios, not android... 奇怪的是,这个问题仅与ios有关,而不与android有关。

I tried adding a style of textAlign: left , but it didn't anything. 我尝试添加textAlign: left样式,但是没有任何作用。 What am I doing wrong, and how can I fix that? 我在做什么错,该如何解决?

Here's a link to the project: https://snack.expo.io/S1PlOqFvN 这是项目的链接https : //snack.expo.io/S1PlOqFvN

import React from 'react';
import { StyleSheet, Text, View, TextInput } from 'react-native';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <TextInput style={styles.textFieldStyling} placeholder="Try typing something..."></TextInput>
        <Text style={styles.textStyling}></Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: 'orange',
    alignItems: 'center',
    justifyContent: 'center',
  },
  textStyling: {
    fontSize: 50,
    textAlign: 'center',
  },
  textFieldStyling: {
      color: 'blue',
  },
});

TextInput in React Native does not have a close tag React Native中的TextInput没有关闭标签

  <TextInput
      style={styles.textFieldStyling} 
      placeholder="Try typing something..."
  />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM