objective c - Date picker Issue in IOS -
i have textfield in user can click opens date picker , after selection , clicking done button paste date in textfield. but, i'm facing issue date picker not showing when click textfield, i'm confused why code think alright don't know why s not showing date picker, code ,
datepicker=[[uidatepicker alloc]init]; datepicker.datepickermode=uidatepickermodedate; uitoolbar *toolbar=[[uitoolbar alloc]initwithframe:cgrectmake(0, 0, 320, 44)]; [toolbar settintcolor:[uicolor blackcolor]]; uibarbuttonitem *donebtn=[[uibarbuttonitem alloc]initwithtitle:@"done" style:uibarbuttonitemstyleplain target:self action:@selector(showselecteddate)]; uibarbuttonitem *space=[[uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:self action:nil]; [toolbar setitems:[nsarray arraywithobjects:donebtn,space,nil]]; the method this,
-(void)showselecteddate{ nsdateformatter *fromatter=[[nsdateformatter alloc]init]; [fromatter setdateformat:@"dd/mm/yyyy"]; self.dob.text=[nsstring stringwithformat:@"%@",[fromatter stringfromdate:datepicker.date]]; }
you missing 1 statement
[mytextfield setinputview: datepicker]; you not adding picker view
[self.view addsubview:datepicker]; to show toolbar missing below statement
textfield.inputaccessoryview = toolbar;
Comments
Post a Comment