how to display images in imageview in iphone

≡放荡痞女 提交于 2019-12-12 19:17:32

问题


Iam new to iphone currently my problem is

i displayed 6 images in 6 image views It was not showing images in imageview I think the imageviews are in large size

i implement code like this.

imageview1 = [[UIImageView alloc] init];
UIImage *img1 = [UIImage imageNamed:@"wolf.jpg"];
[imageview2 setImage:img1];

so plz send me correct code for this imageview.

Thank u in advance.


回答1:


First of all, you're adding the image 1 to imageview 2 - are you sure you want to do this?

Secondly, you need to add the imagview to the view hierarchy, for example by adding it to a ViewControllers view, like this: [[self view] addSubview:imageview1] (If this code is situated within the View Controller class).




回答2:


bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,480,300)];
bgImage.image = [UIImage imageNamed:@"Default.png"];
[self.view addSubview:bgImage];

Also check have you add image file to your project, by Add - > Existing File




回答3:


imageview1 = [[UIImageView alloc] init];
imageview1.image = [UIImage imageNamed:@"wolf.jpg"];


来源:https://stackoverflow.com/questions/4518071/how-to-display-images-in-imageview-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!