【问题标题】:How to have fixed header after keyboard is shown on iOS?在iOS上显示键盘后如何固定标题?
【发布时间】:2019-10-09 00:19:41
【问题描述】:

在 iOS 设备上打开键盘后,固定标题正在滚动。打开键盘后是否有可能固定标题?我不想让标题随着内容滚动。

这里解释了类似的问题: https://medium.com/@im_rahul/safari-and-position-fixed-978122be5f29

我在使用 Cordova 的 React 项目中遇到了问题。

非常感谢您的帮助。

【问题讨论】:

  • 你解决了这个问题吗?

标签: ios reactjs header keyboard


【解决方案1】:

如果您隐藏状态栏,KeyboardAvoiding 会将包括标题在内的所有内容推到顶部,这是 KeyboardAvoidingView 在 react native 中的一个错误。

要在显示键盘时固定标题,请将状态栏设置为 hidden=false

【讨论】:

  • 问题是关于 React.js 而不是 react-native。
【解决方案2】:

使用来自“react-native”的keyboardAvoidingView
docs

   import {
      KeyboardAvoidingView
    } from 'react-native';

<KeyboardAvoidingView behavior="padding" style={styles.container}>


          <View style={styles.inputContainer}>
            <TextInput
              returnKeyType="next"
              placeholder="Mobile No."
              placeholderTextColor="powderblue"
              keyboardType="number-pad"
              onSubmitEditing={() => this.passwordInput.focus()}
              style={styles.input}
               onChangeText={(value) => this.setState({mobileno:value})}
               value={this.state.mobileno}
            />

            <TextInput
              returnKeyType="go"
              placeholder="Password"
              placeholderTextColor="powderblue"
              style={styles.input}
              secureTextEntry
              ref={input => (this.passwordInput = input)}
               onChangeText={(value) => this.setState({pssd:value})}
               value={this.state.pssd}
            />
          </View>



      </KeyboardAvoidingView>

【讨论】:

  • 我没有使用 react-native 那么是否有任何可能的解决方案如何仅使用 React 和 Cordova 来解决这个问题?
猜你喜欢
  • 2012-09-15
  • 1970-01-01
  • 2019-02-13
  • 1970-01-01
  • 2012-09-04
  • 1970-01-01
  • 2016-08-16
  • 1970-01-01
  • 2020-09-20
相关资源
最近更新 更多