【问题标题】:how to display images in imageview in iphone如何在iphone的imageview中显示图像
【发布时间】:2011-10-18 18:56:59
【问题描述】:

我是 iphone 新手,目前我的问题是

我在 6 个图像视图中显示了 6 个图像它没有在 imageview 中显示图像我认为 imageviews 的尺寸很大

我实现这样的代码。

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

所以请给我发送此图像视图的正确代码。

提前谢谢你。

【问题讨论】:

  • 接受问题的答案很重要。请返回您收到有用答案的其他问题,然后单击对您最有帮助的答案旁边的灰色复选标记。
  • 这些答案对你有用吗?如果是,请点击答案旁边的灰色复选标记接受。

标签: iphone uiimageview uiimage


【解决方案1】:
bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,480,300)];
bgImage.image = [UIImage imageNamed:@"Default.png"];
[self.view addSubview:bgImage];

还检查您是否将图像文件添加到项目中,通过添加 -> 现有文件

【讨论】:

    【解决方案2】:

    首先,您要将图像 1 添加到图像视图 2 - 您确定要这样做吗?

    其次,您需要将 imagview 添加到视图层次结构中,例如通过将其添加到 ViewControllers 视图中,如下所示:[[self view] addSubview:imageview1](如果此代码位于 View Controller 类中)。

    【讨论】:

      【解决方案3】:
      imageview1 = [[UIImageView alloc] init];
      imageview1.image = [UIImage imageNamed:@"wolf.jpg"];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-07
        • 1970-01-01
        • 2020-12-16
        • 2014-09-23
        • 1970-01-01
        • 2015-11-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多