Xcode 6 iOS 8 UIImage imageName from package issue

I create my project using iOS 7.1 and try to load the UIImage view with the image stored in the file / images / cars / car _1.png

All images are in the folder images, as shown in the figure below in the project tree:

enter image description here

This way, it works great for iOS 7.1 and Xcode 5, but when I try to use Xcode 6 and iOS 8, the UIImage instance is zero when I try to display the image.

UIImage *image = [UIImage imageNamed:@"/images/cars/car_1.png"];

po image

nil (for iOS 8)

he may also be

UIImage *image = [UIImage imageNamed:@"/images/sport-cars/car_1.png"];

since you can see that the name of the resource is the same car_1.png, but this is normal because they are in folders with different resources, and not in the folders of the package.

+4
2

, , , - , @"/Reference Folder Path/image.jpg", .

"/" .

, , .

+3

iOS 4 , PNG, .PNG. iOS 4 .

, , JPEG.

,

imageNamed imageWithContentsOfFile

NSString *imageFile = [NSString stringWithFormat:@"%@/iphone4/%@", [[NSBundle mainBundle] resourcePath], @"1.png"];
UIImage* image = [UIImage imageWithContentsOfFile:imageFile];

NSString *imageFile1 = [NSString stringWithFormat:@"%@/iphone5/%@", [[NSBundle mainBundle] resourcePath], @"1.png"];
UIImage* image1 = [UIImage imageWithContentsOfFile:imageFile1];

NSString *imageFile2 = [NSString stringWithFormat:@"%@/iphone6/%@", [[NSBundle mainBundle] resourcePath], @"1.png"];
UIImage* image2 = [UIImage imageWithContentsOfFile:imageFile2];

3 ( ). -,

0

All Articles