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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -