5

I'm getting a rare crash when using an iOS date picker.

The crash is: NSInternalInconsistencyException Failed to allocate data stores for 100000 rows in section 0. Consider using fewer rows

UITextField *dateinput = [[UITextField alloc] initWithFrame:CGRectMake(26, yOffset, 268, 35)];
[dateinput setPlaceholder:@"Ends:"];
[dateinput setText:@""];
[self configureTextField:dateinput];
[footer addSubview:dateinput];
[self setDateinput:dateinput];

UILabel* dateinputLabel = [[UILabel alloc] initWithFrame: CGRectMake(26, yOffset - 21, 268, 30.0f)];
[dateinputLabel setTextColor:[UIColor colorWithRGBHex:0x777777]];
[dateinputLabel setFont:[UIFont fontWithName:@"Helvetica" size:11]];
[dateinputLabel setBackgroundColor:[UIColor clearColor]];
dateinputLabel.text = @"End Date";
[footer addSubview:dateinputLabel];

UIDatePicker *datePicker = [[UIDatePicker alloc] init];
[datePicker setDatePickerMode:UIDatePickerModeDate]; //crash on this line
[dateinput setInputView:datePicker];

For some reason the date picker is internally allocating a huge number of rows and crashing because not that many rows are available.

Is it correct behaviour for the date picker to allocate so many rows? And if not, can anyone see what I'm doing that is causing this odd behaviour?

Note that I haven't been able to replicate this issue. It's clear that a small number of users are being affected (via crashlytics)

agent tom
  • 51
  • 2
  • Did you try setting a minimumDate/maximumDate? Why do you add the date picker as a input view of a text field? – artey Jan 03 '13 at 23:24
  • Thanks @Andy I'll try setting a min/max date to see if that helps. I'm not totally sure why it's being set as the input view of a text field (this is a legacy project). You're quite right that this is also weird. I'll set min/max date and I'll make the date input direct instead of via a textfield. – agent tom Jan 03 '13 at 23:31
  • Please file a bug, including a sample project that reproduces this issue. `UIDatePicker` should not be crashing. https://bugreport.apple.com – Dave DeLong Jan 05 '13 at 06:51
  • I'm getting this crash from customers too. It's while trying to allocate a viewController with a date picker in it and I can't reproduce it. The stack trace doesn't even hit the viewDidLoad method on the VC in question. I tried setting a min/max now as well so we'll see if that fixes it. – Eclectic DNA Jan 09 '13 at 18:25
  • hi ,were you able to fix this bug??? even i am struck with same bug..... – raja Mar 12 '13 at 06:35

0 Answers0