heyred
heyred

Reputation: 2051

Image not displaying in image view

I have an iPhone application that displays details of local businesses. I read the business details from a .csv file to first show all businesses in a UITableViewController, and then depending on the selection, show the details for each business in a UIViewController.

All information is displaying and working as intended, except for my images - they are not displaying. I have created an IBOutlet for them same as for all the other labels and this is how I set the image in the UIViewController in viewDidLoad():

self.businessImage.image
= [UIImage imageNamed:businessDetailContent.imageName];

Where businessDetailContent.imageName is a NSObject that holds the business' details. All images are also imported and present. When I NSLog after the above code, I can see the image is present, but its not showing up on my UIViewController.

And here is how the information in the .csv file looks

ID, name, address, tel, email, URL, description, hotel_someHotelName

Where hotel_someHotelName is the name of the image file (hotel_someHotelName.jpg). I have tried adding the .jpg extension to the end of hotel_someHotelName in .csv but still no image.

Some of the images are low quality, so may this be the issue?

Upvotes: 0

Views: 73

Answers (2)

heyred
heyred

Reputation: 2051

Just found my issue. In my .csv file, the image name had a space after the image name. When I removed this space (purely found by accident), the images are working fine.

Thanks for all the help all the same

Upvotes: 0

matt
matt

Reputation: 535140

You are saying:

self.businessImage.image = [UIImage imageNamed:businessDetailContent.imageName];

And no image is appearing in your interface. So there are three possibilities:

  • [UIImage imageNamed:businessDetailContent.imageName] is nil

  • self.businessImage is nil

  • self.businessImage is a nonnil image view, and you are successfully assigning it an image, but that image view is not in your interface (or constraints are resizing it to zero size so that it is effectively invisible)

The first two may be readily tested by careful logging. One way to test the third possibility is to give the image view a colored background (set its backgroundColor; you can do this in Interface Builder too). If you still don't see it, that's the problem.

Upvotes: 2

Related Questions