首页 > 解决方案 > iOS DatePicker 在 React Native 中不显示

问题描述

我在 iOS 上看不到我的 DatePicker。模式已打开,但没有任何可见的内容,当我在模式内移动 DatePicker 时,日期会发生变化,所以我知道它可以工作。它只是看不见的,我不知道为什么。

你能帮我吗?

谢谢

type Props = {
  date: Date,
  updateDate: Function
}

type State = {

}

export class DatePickerComponent extends React.Component<Props, State> {
  constructor(Props: Object) {
    super(Props);
  }

  render() {
    return (
      <DatePicker 
        cancelBtnText="Annuler"
        confirmBtnText="Valider"
        customStyles={{
          dateIcon: {
            position: 'absolute',
            left: 5,
            marginLeft: 0
          },
          dateInput: {
            marginLeft: 45
          }
        }}
        date={this.props.date}
        format="DD-MM-YYYY"
        iconSource={require("../../assets/Birthday.png")}
        locale="fr"
        onDateChange={(date) => this.props.updateDate(date)}
        style={{width: "60%", marginTop: 15}}
      />
    );
  }
} 

标签: reactjsreact-nativedatepicker

解决方案


1.打开Info.plist。2.添加这些:

  <key>UIUserInterfaceStyle</key>
  <string>Light</string>

推荐阅读