Friday, 15 August 2014

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



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

after updated ios8, cordova datepicker plugin not work. crashed next message:

terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'uitableview datasource not set'

but don't see uitableview related code in plugin source code. don't know, maybe there internal uitableview in uidatepicker?

here code(i remove non-relative code 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 line, 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]; homecoming popover; }

this line:

self.datepicker.date = [formatter datefromstring:datestring];

finally leads crash, , debug, found value of datestring is:

2014-10-17t10:0:00z

2014-10-17t20:0:00z

and crash sec display, first time ok

could please give me clue? thanks

finally find out issue:

the source code of cordova datepicker, reuse uidatepicker instance:

if(!self.datepicker){ self.datepicker = [self createdatepicker]; [self.datepicker addtarget]; }

and, works fine in ios7, lead crash in ios8.

in ios8, don't share uidatepicker instance in multi uiview, modify code to:

// in ios8, uidatepicker couldn't shared in multi uiviews, cause crash. 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 can help me

uitableview cordova datepicker ios8 uidatepicker

No comments:

Post a Comment