cordova datepicker plugin not working in iOS8: UITableView dataSource is not set

michael

after updated to iOS8, the cordova datepicker plugin not work. it crashed with following message:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource is not set'

but i don't see any UITableView related code in the plugin source code. i don't know, maybe there is an internal UITableView in the UIDatePicker?

here is the code(i remove some non-relative code for easy reading):

- (UIPopoverController *)createPopover:(NSMutableDictionary *)options {

  UIView *datePickerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, pickerViewWidth, pickerViewHeight)];

  if(!self.datePicker){
    self.datePicker = [self createDatePicker:options frame:frame];
    [self.datePicker addTarget:self action:@selector(dateChangedAction:) forControlEvents:UIControlEventValueChanged];
  }

  NSDateFormatter *formatter = [self createISODateFormatter:@"yyyy-MM-dd'T'HH:mm:ss'Z'" timezone:[NSTimeZone defaultTimeZone]];
  NSString *dateString = [options objectForKey:@"date"];
  self.datePicker.date = [formatter dateFromString:dateString];// if remove this line, it works fine

  [datePickerView addSubview:self.datePicker];

  UIViewController *datePickerViewController = [[UIViewController alloc]init];
  datePickerViewController.view = datePickerView;

  UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:datePickerViewController];
  popover.delegate = self;
  [popover setPopoverContentSize:CGSizeMake(pickerViewWidth, pickerViewHeight) animated:NO];

  [popover presentPopoverFromRect:anchor inView:self.webView.superview  permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];   

  return popover;
}

this line:

self.datePicker.date = [formatter dateFromString:dateString];

finally leads to crash, and with debug, i found the value of dateString is:

2014-10-17T10:0:00Z

2014-10-17T20:0:00Z

and it crash from second display, the first time is always ok

could you please give me some clue? thanks

michael

finally i find out the issue:

the source code of cordova DatePicker, reuse the UIDatePicker instance:

if(!self.datePicker){
    self.datePicker = [self createDatePicker];
    [self.datePicker addTarget];
}

and, it works fine in iOS7, but lead to crash in iOS8.

in iOS8, don't share UIDatePicker instance in multi UIView, so i modify the code to:

// in iOS8, UIDatePicker couldn't be shared in multi UIViews, it will cause crash. so   create new UIDatePicker instance every time
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {

    self.datePicker = [self createDatePicker:options frame:frame];
    [self.datePicker addTarget:self action:@selector(dateChangedAction:) forControlEvents:UIControlEventValueChanged];

}else{

    if(!self.datePicker){
        self.datePicker = [self createDatePicker:options frame:frame];
        [self.datePicker addTarget:self action:@selector(dateChangedAction:) forControlEvents:UIControlEventValueChanged];
    }
}

hope this can help someone like me

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Phonegap / Cordova not working in ios8

From Dev

Phonegap / Cordova not working in ios8

From Dev

Razorpay cordova plugin not working for iOS

From Dev

set delegate and dataSource to UITableView

From Dev

UITableView didSelectRowAtIndexPath not working after upgrade to iOS8

From Dev

UITableView Swipe to delete not working properly on iOS8

From Dev

UITableView Swipe to delete not working properly on iOS8

From Dev

Cordova geoLocation plugin in iOS not working fine

From Dev

cordova-plugin-camera not working in IOS

From Dev

Cordova & Ionic on ios - Device plugin not working

From Dev

Cordova "Console" plugin not working

From Dev

Cordova NFC plugin not working

From Dev

Cordova "Console" plugin not working

From Dev

UITextView scrollEnabled = YES not working after set scrollEnabled = NO in iOS8

From Dev

How can I programmatically set dataSource of UITableView?

From Dev

Cordova Push Plugin iOS 8

From Dev

Cordova katzer plugin background mode not working on iOS-9

From Dev

Cordova Ionic email plugin not working on iOS 9 due to URL

From Dev

Cordova katzer plugin background mode not working on iOS-9

From Dev

cordova custom datepicker plugin display only years

From Dev

cordova cordova-plugin-statusbar StatusBarOverlaysWebView not working

From Dev

Cordova Media Plugin setVolume() not working

From Dev

iOS8 UILocalNotification not working

From Dev

iOS8 UILocalNotification not working

From Dev

UIActionSheet with Datepicker in IOS8 Xamarin Replacement

From Dev

Cordova file-transfer plugin not working in simulator

From Dev

UIPanGestureRecognizer in UITableView does not work on iOS8

From Dev

custom UItableView not displaying correctly on ios8

From Dev

How to add UITableview in UIAlertController in iOS8?

Related Related

  1. 1

    Phonegap / Cordova not working in ios8

  2. 2

    Phonegap / Cordova not working in ios8

  3. 3

    Razorpay cordova plugin not working for iOS

  4. 4

    set delegate and dataSource to UITableView

  5. 5

    UITableView didSelectRowAtIndexPath not working after upgrade to iOS8

  6. 6

    UITableView Swipe to delete not working properly on iOS8

  7. 7

    UITableView Swipe to delete not working properly on iOS8

  8. 8

    Cordova geoLocation plugin in iOS not working fine

  9. 9

    cordova-plugin-camera not working in IOS

  10. 10

    Cordova & Ionic on ios - Device plugin not working

  11. 11

    Cordova "Console" plugin not working

  12. 12

    Cordova NFC plugin not working

  13. 13

    Cordova "Console" plugin not working

  14. 14

    UITextView scrollEnabled = YES not working after set scrollEnabled = NO in iOS8

  15. 15

    How can I programmatically set dataSource of UITableView?

  16. 16

    Cordova Push Plugin iOS 8

  17. 17

    Cordova katzer plugin background mode not working on iOS-9

  18. 18

    Cordova Ionic email plugin not working on iOS 9 due to URL

  19. 19

    Cordova katzer plugin background mode not working on iOS-9

  20. 20

    cordova custom datepicker plugin display only years

  21. 21

    cordova cordova-plugin-statusbar StatusBarOverlaysWebView not working

  22. 22

    Cordova Media Plugin setVolume() not working

  23. 23

    iOS8 UILocalNotification not working

  24. 24

    iOS8 UILocalNotification not working

  25. 25

    UIActionSheet with Datepicker in IOS8 Xamarin Replacement

  26. 26

    Cordova file-transfer plugin not working in simulator

  27. 27

    UIPanGestureRecognizer in UITableView does not work on iOS8

  28. 28

    custom UItableView not displaying correctly on ios8

  29. 29

    How to add UITableview in UIAlertController in iOS8?

HotTag

Archive