I am trying to update the date and time displayed in a table cell immediately after the UIPicker's data has changed (real time updated). I implemented the following code. My "update" method is not being called despite changing the values in the picker. Can anyone advise? Thanks!
Zhen
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger row = [indexPath row];
if (row == 0)
{
self.picker.hidden = NO;
[self.picker addTarget:self action:@selector(updateDate) forControlEvents:UIControlEventTouchUpInside];
}
}
- (void)updateDate
{
selectedDate = [self.picker date];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"dd-MM-yyyy HH:mm"];
selectedDateString = [formatter stringFromDate:selectedDate];
[tableView reloadData];
}