Reputation: 329
I have a textfield
within a tableviewcell
. I want to be able to display a UITableViewCellAccessoryCheckmark
on clicking within the textfield. How do i do that ? Please help. Thanks in Advance.
Upvotes: 0
Views: 1468
Reputation: 2314
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = [[managedObject valueForKey:@"key"] description];
if ([self.selectedCellValue isEqualToString:[[managedObject valueForKey:@"key"] description]]) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
self.selectedCellValue = [[managedObject valueForKey:@"key"] description];
[self.myTableView reloadData];
}
If you are using Core Data then go with fetchedresulcontroller. Otherwise use your array in place of that.
Upvotes: 2
Reputation: 3693
use the
-(void)textFieldDidBeginEditing:(UITextField *)textField {
//get the cell and change its accessory type to check mark
}
Upvotes: 0