Note that there are some explanatory texts on larger screens.

plurals
  1. POError reloading custom cell after changing data
    primarykey
    data
    text
    <p>I have a set up tableView which works fine. As you can see below I want to add an image to my cell when the value for the object @"sent" changes to @"yes". After this is done i call [sendTable reloadData] but nothing happens to the tableView. Only when I restart the app my image is properly shown in the cell. So obviously reloadData isn't doing anything here. </p> <p>Can anybody figure out the problem?</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell; if (tableView == sendTable) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"savedItems.plist"]; savedItemsArray = [NSMutableArray arrayWithContentsOfFile:writableDBPath]; NSDictionary* item = [savedItemsArray objectAtIndex:indexPath.row]; NSString *temp = [NSString stringWithFormat:@"%@,%@", [[savedItemsArray valueForKey:@"name"]objectAtIndex:indexPath.row], [[savedItemsArray valueForKey:@"message"]objectAtIndex:indexPath.row]]; UIView *background; cell = [self.sendTable dequeueReusableCellWithIdentifier:temp]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:temp]; cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton; cell.selectionStyle = UITableViewCellSelectionStyleGray; background = [[UIView alloc] initWithFrame:cell.frame]; [cell addSubview:background]; [cell sendSubviewToBack:background]; } if ([[item objectForKey:@"sent"] isEqualToString: @"no"]) { UILabel *personLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, cell.frame.size.width-150, 20)]; personLabel.backgroundColor = [UIColor clearColor]; personLabel.text = [NSString stringWithFormat: @"%@",[item objectForKey:@"name"]]; personLabel.font = [UIFont boldSystemFontOfSize:17]; UILabel *personLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, cell.frame.size.width-150, 20)]; personLabel2.backgroundColor = [UIColor clearColor]; personLabel2.text = [NSString stringWithFormat: @"(%@)", [item objectForKey:@"number"]]; personLabel2.font = [UIFont systemFontOfSize:15]; UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(cell.frame.size.width-125, 10, 80, 40)]; dateLabel.backgroundColor = [UIColor clearColor]; dateLabel.text = [NSString stringWithFormat: @"%@\n%@",[item objectForKey:@"date"], [item objectForKey:@"time"]]; dateLabel.textColor = [UIColor darkGrayColor]; dateLabel.textAlignment = NSTextAlignmentRight; dateLabel.font = [UIFont systemFontOfSize:13]; dateLabel.numberOfLines = 2; UILabel *messageLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, cell.frame.size.width-50, 20)]; messageLabel.backgroundColor = [UIColor clearColor]; messageLabel.text = [NSString stringWithFormat: @"%@",[item objectForKey:@"message"]]; messageLabel.textColor = [UIColor lightGrayColor]; messageLabel.font = [UIFont systemFontOfSize:15]; [background addSubview:personLabel]; [background addSubview:personLabel2]; [background addSubview:dateLabel]; [background addSubview:messageLabel]; [cell addSubview:background]; }else{ UILabel *personLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 10, cell.frame.size.width-170, 20)]; personLabel.backgroundColor = [UIColor clearColor]; personLabel.text = [NSString stringWithFormat: @"%@",[item objectForKey:@"name"]]; personLabel.font = [UIFont boldSystemFontOfSize:17]; UILabel *personLabel2 = [[UILabel alloc]initWithFrame:CGRectMake(40, 30, cell.frame.size.width-170, 20)]; personLabel2.backgroundColor = [UIColor clearColor]; personLabel2.text = [NSString stringWithFormat: @"(%@)", [item objectForKey:@"number"]]; personLabel2.font = [UIFont systemFontOfSize:15]; UILabel *dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(cell.frame.size.width-125, 10, 80, 40)]; dateLabel.backgroundColor = [UIColor clearColor]; dateLabel.text = [NSString stringWithFormat: @"%@\n%@",[item objectForKey:@"date"], [item objectForKey:@"time"]]; dateLabel.textColor = [UIColor darkGrayColor]; dateLabel.textAlignment = NSTextAlignmentRight; dateLabel.font = [UIFont systemFontOfSize:13]; dateLabel.numberOfLines = 2; UILabel *messageLabel = [[UILabel alloc]initWithFrame:CGRectMake(40, 60, cell.frame.size.width-80, 20)]; messageLabel.backgroundColor = [UIColor clearColor]; messageLabel.text = [NSString stringWithFormat: @"%@",[item objectForKey:@"message"]]; messageLabel.textColor = [UIColor lightGrayColor]; messageLabel.font = [UIFont systemFontOfSize:15]; UIImage *checkmarkImage = [UIImage imageNamed:@"done.png"]; UIImageView *checkmark = [[UIImageView alloc] initWithImage:checkmarkImage]; [checkmark setFrame:CGRectMake(10, 35, 20, 20)]; [background addSubview:personLabel]; [background addSubview:personLabel2]; [background addSubview:dateLabel]; [background addSubview:messageLabel]; [background addSubview:checkmark]; [cell addSubview:background]; } } return cell; } </code></pre> <p>Thanks a lot!</p>
    singulars
    1. This table or related slice is empty.
    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