ios - How can I convert imageNamed to imageWithContentsOfFile? -


i tried convert imagenamed: imagewithcontentsoffile: , failed everytime. not see pictures on cells.

uiimage *image = [uiimage imagenamed:[cellcountry objectforkey:@"country_flag"]]; cell.imageview.image = image; 

[cellcountry objectforkey:@"country_flag"] holds flag1@2x.png

path of image files /resources/images

and attempt.

uiimage *image = [uiimage imagewithcontentsoffile:[[nsbundle mainbundle] pathforresource:[cellcountry objectforkey:@"country_flag"] oftype:@"png"]]; cell.imageview.image = image; 

how can convert it? waiting help...

your attempt use imagewithcontentsoffile close. since value [cellcountry objectforkey:@"country_flag"] has file extension, can't specify extension when getting path.

try:

uiimage *image = [uiimage imagewithcontentsoffile:[[nsbundle mainbundle] pathforresource:[cellcountry objectforkey:@"country_flag"] oftype:nil]]; 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -