bhavya kothari
bhavya kothari

Reputation: 7474

why image is not displayed in UIImageView?

UIImage *image = [UIImage imageNamed:[currentPhoto fileName]];
NSLog(@"%@",[currentPhoto fileName]);
[self.currentImage setImage:image];

its displays the correct image name in debug area which i want to display on UIImageView. currentImage is outlet hooked in .h file

Is it because of new Auto-layout feater of iOS 6 i am not getting it. It used to work in iOS 5.

My purpose is to display image in an UIImageView on a particular Scene

I have also tried to set Default image which i have copied in my project folder. But i am getting an error debug area as follows:

Could not load the "myImage.png" image referenced from a nib in the bundle with identifier "com.xxx.xxx"

Upvotes: 1

Views: 2009

Answers (3)

bhavya kothari
bhavya kothari

Reputation: 7474

When you go to File-->Add Files "ProjectName" Below windows pops up.
And Default option selected by Xcode was "Create folder references for any added folders" as shown pic below which was producing
Error(in Debug area) :
Could not load the "myImage.png" image referenced from a nib in the bundle with identifier "com.xxx.xxx"

Wrong options selected

Solution to above Problem :
Select "Create groups for any added folders" which Xcode generally select was not the case this time.

enter image description here


Solution is so simple but sometimes silly mistakes happens.

Upvotes: 1

Tony Thomas
Tony Thomas

Reputation: 1005

If your image is not added to the project, it wont be available for imageNamed call.To load the image which is not added to the project use this call

UIImage * image = [UIImage imageWithContentsOfFile:imgFilePath];

Upvotes: 0

Xcoder
Xcoder

Reputation: 1807

Make sure that image name carries the extension(.jpg/.png) as well. Also have you defined an iBoutlet for the imageView??

Also if the problem is with autolayout,you can disable it in the Xib. Learn it from here. http://www.goodbyehelicopter.com/2012/02/arggh-xcode-4-3-auto-layout-is-on-by-default-how-to-turn-off-auto-layout/

Upvotes: 2

Related Questions