display checkmark accessory type when clicking within textfield in tableview cell
I have a textfield
within a tableviewcell
. I want to be able to display a UITableViewCellAccessory开发者_StackOverflow中文版Checkmark
on clicking within the textfield. How do i do that ? Please help. Thanks in Advance.
- (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.
use the
-(void)textFieldDidBeginEditing:(UITextField *)textField {
//get the cell and change its accessory type to check mark
}
精彩评论