开发者

how can i assign image name to 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜