beefe / react-native-picker

A Native Picker with high performance.
1.75k stars 785 forks source link

ios8 Picker.init date 闪退 #344

Open lenvonsam opened 6 years ago

lenvonsam commented 6 years ago
function createDate(startYear = 1950, len = 80) {
  const endYear = startYear + len
  let dateData = []
  for (let y = startYear; y <= endYear; y++) {
    let month = []
    for (let m = 1; m <= 12; m++) {
      let day = []
      if (m === 2) {
        for (let d = 1; d < 29; d++) {
          day.push((d < 10 ? '0' + d : '' + d))
        }
        if (((y % 4 === 0) && (y % 100 > 0)) || (y % 400 === 0)) day.push('29')
      } else if (([1, 3, 5, 7, 8, 10, 12].findIndex(it => it === m)) >= 0) {
        for (let d = 1; d <= 31; d++) {
          day.push((d < 10 ? '0' + d : '' + d))
        }
      } else {
        for (let d = 1; d <= 30; d++) {
          day.push((d < 10 ? '0' + d : '' + d))
        }
      }
      let _month = {}
      _month[(m < 10 ? '0' + m : '' + m)] = day
      month.push(_month)
    }
    let _year = {}
    _year['' + y] = month
    dateData.push(_year)
  }
  return dateData
}

Picker.init({
      pickerData: createDate(),
      pickerTitleText: config.title || '',
      selectedValue: defaultSelectedValue,
      pickerConfirmBtnText: config.confirmText || '确认',
      pickerCancelBtnText: config.cancelText || '取消',
      onPickerConfirm: config.confirm,
      onPickerCancel: pickedValue => {
        config.cancel()
      },
      pickerToolBarBg: config.toolbarBg || [255, 255, 255, 1],
      pickerBg: config.pickerBg || [250, 250, 250, 0.8]
    })
Picker.show()

在ios8以上的操作系统都正常,但在ios8上报这个错误 image

RN版本是0.52.3

lenvonsam commented 6 years ago

anybody can help me slove this problem?