ios - UIDatePicker with UIToolbar -
i'm trying implement uitoolbar on uidatepicker dismiss when touching "done" button. when tap on button, datepicker scrolling , action button doesn't work.
here code :
datepicker = [[uidatepicker alloc] initwithframe:cgrectzero]; [datepicker setdatepickermode:uidatepickermodedate]; [datepicker addtarget:self action:@selector(changedate:) forcontrolevents:uicontroleventvaluechanged]; uitoolbar *toolbar= [[uitoolbar alloc] initwithframe:cgrectmake(0,0,self.view.frame.size.width,44)]; toolbar.barstyle = uibarstyledefault; uibarbuttonitem *flexiblespaceleft = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil]; uibarbuttonitem* donebutton = [[uibarbuttonitem alloc] initwithtitle:@"done" style:uibarbuttonitemstyledone target:self action:@selector(dismiss)]; [toolbar setitems:[nsarray arraywithobjects:flexiblespaceleft, donebutton, nil]]; [datepicker addsubview:toolbar];
my datepicker :
thank help.
if use uitextfield set
textfield.inputaccessoryview = toolbar; textfield.inputview = datepicker;
Comments
Post a Comment