Reputation: 97
I am in the process of converting the Apple DateCell app to use UIPickerView instead of UIDatePicker. I've pulled out and replaced references to UIDatePicker with UIPickerView in storyboard and throughout the code. Still have some clean up to do on the references to DatePicker but, I am at a point where i need to convert the reference to the "dateAction" method from the "ValueChanged" event of the UIDatePicker and there is no "Send Events" what so ever for UIPickerView. Does anyone have any suggestions on how I can add or simulate this "ValueChanged" event to my UIPickerView? Also, any advice on converting the rest of the program to use UIPickerView would be greatly appreciated.
- (IBAction)dateAction:(id)sender
{
NSIndexPath *targetedCellIndexPath = nil;
if ([self hasInlineDatePicker])
{
// inline date picker: update the cell's date "above" the date picker cell
//
targetedCellIndexPath = [NSIndexPath indexPathForRow:self.datePickerIndexPath.row - 1 inSection:0];
}
else
{
// external date picker: update the current "selected" cell's date
targetedCellIndexPath = [self.tableView indexPathForSelectedRow];
}
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:targetedCellIndexPath];
UIPickerView *targetedDatePicker = sender;
// update our data model
NSMutableDictionary *itemData = self.dataArray[targetedCellIndexPath.row];
[itemData setValue:targetedDatePicker.date forKey:kDateKey];
// update the cell's date string
cell.detailTextLabel.text = [self.dateFormatter stringFromDate:targetedDatePicker.date];
}
Upvotes: 3
Views: 1026