开发者

display checkmark accessory type when clicking within textfield in tableview cell

开发者 https://www.devze.com 2023-02-19 07:40 出处:网络
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.

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 
}
0

精彩评论

暂无评论...
验证码 换一张
取 消