how to display images in imageview in iphone

2019-07-16 23:41发布

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.

3条回答
冷血范
2楼-- · 2019-07-17 00:26

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).

查看更多
【Aperson】
3楼-- · 2019-07-17 00:27
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

查看更多
何必那么认真
4楼-- · 2019-07-17 00:31
imageview1 = [[UIImageView alloc] init];
imageview1.image = [UIImage imageNamed:@"wolf.jpg"];
查看更多
登录 后发表回答