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
Post a Comment