IOS:Fatal Exception: NSRangeException

后端 未结 4 1932
误落风尘
误落风尘 2021-01-02 12:46

The app work fine before iOS 11 update. After iOS 11 rollout, some user get this below crash but I cannot reproduce this in simulator iOS 11. Based on fabric.io, not all iOS

4条回答
  •  误落风尘
    2021-01-02 12:49

    We saw the same issue in our app and were able to fix by setting the date picker's calendar type to 'Gregorian' BEFORE setting any other date picker property, e.g.

    self.inputDatePicker = [[DatePickerView alloc] init...];
    self.inputDatePicker.calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]
    self.inputDatePicker.datePicker.datePickerMode = UIDatePickerModeDate;
    self.inputDatePicker.delegate = self;
    

    We reproduced on an iOS11 iPhone 6S by changing the user's calendar to Buddhist.

    For some reason the app would crash if we set the calendar AFTER setting the date picker mode... seems like an Apple bug to force devs to have to think about the order in which we set our properties.

提交回复
热议问题