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 :

uidatepicker

thank help.

if use uitextfield set

textfield.inputaccessoryview = toolbar; textfield.inputview = datepicker; 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -