Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The cells get reused. You need to reset the accessoryView each time. Its just a small change:</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TopicCell"]; GPBTopic *topic = [self.topics.list objectAtIndex:indexPath.row]; cell.textLabel.text= topic.name; if ((indexPath.row == 5) || (indexPath.row == 9)) { cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"lock_icon.png"]]; [cell.accessoryView setFrame:CGRectMake(0, 0, 24, 24)]; } else { cell.accessoryView = nil; } return cell; } </code></pre> <p>Just for completion, you can also use Eric's solution like this - it may be faster, since the imageView is not created every time. But thats only a minimal difference. Probably your lags have other reasons.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = nil; if(indexPath.row == 5 || indexPath.row == 9) { cell = [tableView dequeueReusableCellWithIdentifier:@"TopicCellWithImage"]; cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"lock_icon.png"]];; [cell.accessoryView setFrame:CGRectMake(0, 0, 24, 24)]; } else { cell = [tableView dequeueReusableCellWithIdentifier:@"TopicCell"]; } GPBTopic *topic = [self.topics.list objectAtIndex:indexPath.row]; cell.textLabel.text= topic.name; return cell; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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