Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd permanent checkmark to tableView-cell
    primarykey
    data
    text
    <p>my viewController contains a tableView where the user can add cells via coreData. I defined the cells:</p> <pre><code> - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Travel"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; NSManagedObject *travel = [self.travelling objectAtIndex:indexPath.row]; UILabel *countryLabel = (UILabel *)[cell viewWithTag:101]; kategorieLabel.text = [travel valueForKey:@"country"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal]; [button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside]; button.frame = CGRectMake(15.0f, 32.0f, 24.0f, 20.0f); [cell addSubview:button]; if ([[travel valueForKey:@"tick"] isEqualToString:@"yes"]) { [cell setAccessoryType:UITableViewCellAccessoryCheckmark]; }else{ [cell setAccessoryType:UITableViewCellAccessoryNone]; } return cell; } - (void)buttonTapped:(UIButton *)sender { UITableViewCell *owningCell = (UITableViewCell*)[sender superview]; [owningCell setAccessoryType:UITableViewCellAccessoryCheckmark]; NSIndexPath *indexPath = [_tableView indexPathForCell:owningCell]; NSManagedObject *travel = [self.travelling objectAtIndex:indexPath.row]; [travel setValue:@"yes" forKey:@"tick"]; } </code></pre> <p>When the user taps a button on the cell, the checkmark should appear. But when I reload or restart the app not all checkmarks are there. Maybe there is a better method to do this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload