开发者

how can i assign image name to string variable

开发者 https://www.devze.com 2023-01-15 12:15 出处:网络
I am new to iPhone. What i need is i have to assign image name (eg.parrot.jpg) to NSString value.i need to display image in imageview using this开发者_JAVA百科 string variable.

I am new to iPhone. What i need is i have to assign image name (eg.parrot.jpg) to NSString value.i need to display image in imageview using this开发者_JAVA百科 string variable.

apporxmatly imageview.image = NSStringvarible; where NSStringVArible is image name.

How can i done this?


NSString *imageName = @"parrot.jpg";

UIImageView *view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];


youreImageView.image = [UIImage imageNamed:@"parrot.jpg"];


You can use

imageview.image = [UIImage imageNamed:NSStringvarible];

as imageview.image needs image and not simple string... So you line will give you warning and will terminate the application Use the above line will help you solve the problem...

hAPPY iCODING...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号