Note that there are some explanatory texts on larger screens.

plurals
  1. POThe right way of showing images on UITableView?
    primarykey
    data
    text
    <p>I am developing an app, that takes events from 3 different shared calendars, and show them, sorted by date, in a UITableView. first calendar is for "Sports Shown on TV" second calendar is for "Live Music on Stage" third calendar is for fixed events (like every thursday is "ladies night")</p> <p>I would like to show a small image on the cell, and the image needs to change according to the event. The way I do it now is to just write the image filename in the event description, and use that to set the image.</p> <pre><code>cell.imageView.image = [UIImage imageNamed:[entry valueForKeyPath:@"content.$t"]]; </code></pre> <p>What i would like to do was to set the image according to either the calendar name, or maybe the contents of the event title</p> <p>I tried</p> <pre><code>NSArray *gdWho = entry[@"gd$who"]; NSString *calendar = gdWho[0][@"valueString"]; if([calendar isEqualToString:@"Live Music on Stage"]) { cell.imageView.image = [UIImage imageNamed:@"music-notes-40x40.jpg"]; } </code></pre> <p>and it works, but as soon as i scroll the tables they get mixed up. I read somewhere that this is an expected outcome, as the cells indexpath change when scrolling, thus rendering my code unusable. </p> <p>But how would you do it then. Could anyone point me in the right direction - I would really like to able to put an image of the artist playing live on stage, so my optimal solution would be to display an image if the NSString = <code>[entry valueForKeyPath:@"title.$t"]</code> contained for example the name "dennis"</p>
    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. 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