Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 740139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:28:51+00:00 2026-05-14T08:28:51+00:00

I have a table in which I want a dynamic image to load in

  • 0

I have a table in which I want a dynamic image to load in at the left-hand side. The table needs to use an IF statement to select the appropriate image from the “Resources” folder, and needs to be based upon [dog types].

The [dog types] is extracted from an RSS feed, and so the image in the table cell needs to match the each cell’s [dog types] tag.

Update: See code below for what I’m looking to do (only below it’s for earthquakes, for me its pictures of dogs).

I suspect I need to use – (UIImage *)imageForTypes:(NSString *)types { to do such a thing.

Thanks.

Updated code: This is for Apple’s Earthquake sample but does exactly what I need to do. It matches images to the severity (2.0, 3.0, 4.0, 5.0 etc.) of every earthquake to the magnitude.

- (UIImage *)imageForMagnitude:(CGFloat)magnitude { 
    if (magnitude >= 5.0) {
        return [UIImage imageNamed:@"5.0.png"];
    }
    if (magnitude >= 4.0) {
        return [UIImage imageNamed:@"4.0.png"];
    }
    if (magnitude >= 3.0) {
        return [UIImage imageNamed:@"3.0.png"];
    }
    if (magnitude >= 2.0) {
        return [UIImage imageNamed:@"2.0.png"];
    }
    return nil;
}

and under – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

magnitudeImage.image = [self imageForMagnitude:earthquake.magnitude];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:28:52+00:00Added an answer on May 14, 2026 at 8:28 am

    The image is set in

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    

    You might want to have that method anyway, for brevity, but you just set the image as you would set a static one.

    Edit: That is to say; in that particular method:

    cell.imageView.image = [UIImage imageNamed:@"Dachshund"]; // Dachshund.jpg exists in the resources directory, of course.
    

    Re-edit: To be even more precise:

    // Assuming that a) [dog types] is "<name of dog type>" and;
    // b) an image named "<name of dog type>.file_extension" exists in the resources of the project:
    cell.image = [UIImage imageNamed:[[dog types] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
    // No mapping of the string to image name is necessary if you know the
    // set of strings that will be used for the feed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table for which I want to select top the 5 rows
I have one table which display data as from Dynamic Content, I want to
I have table which contains the rows that are dynamic from server side scripting(PHP)
I am dynamically creating a table which I want to have clickable rows. When
I have a repeater control outputting some HTML. I want a table which outputs
i have a GridView (selectable) in which I want to generate a dynamic GridView
I have a users table which I want to display like the Stack Overflow
Hi I want to have two tables each have an INT id column which
I have a table which is full of arbitrarily formatted phone numbers, like this
I have a table which is referenced by foreign keys on many other tables.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.