UIDatePicker inside UITableViewCell glitch, covered and hidden

385 Views Asked by At

UIDatePicker inside UITableViewCell created in UITableViewController by Xcode 6.1 for iOS 7.1 dev. How to fix it ?

UIDatePicker middle part hidden by semi translucent rectangle

1

There are 1 best solutions below

0
On BEST ANSWER

In my opinion, the best way to use and datePicker, with a tableView where you have a UITextField. (If you have a label, change this to a UITextField). It´s put the datePicker as inputView of the textField. Here an example:

 // I have a textField as UITextField property in my UITableViewCell (self.foourthCell).
 UIDatePicker *datePicker = [[UIDatePicker alloc] init];
  datePicker.datePickerMode = UIDatePickerModeDate;
NSDateFormatter *format = [[NSDateFormatter alloc] init];
[format setDateFormat:@"dd-mm-yyyy"];
NSDate *date = [format dateFromString:@"01-01-1985"];
[datePicker setDate:date];
[datePicker addTarget:self action:@selector(updateDateOfBirth:) forControlEvents:UIControlEventValueChanged];
[self.fourthCell.textField setInputView:datePicker];