【问题标题】:Is there a way to add images of type .jpeg , .gif and tiff... etc in iphone sdk?有没有办法在 iphone sdk 中添加 .jpeg 、 .gif 和 tiff... 等类型的图像?
【发布时间】:2010-10-14 19:14:23
【问题描述】:

我遇到了一个问题,即如何在 iphone sdk 中显示 .jpeg 和其他类型的文件。有没有办法解决这个问题。请帮帮我。

谢谢你, 马丹·莫汉。

【问题讨论】:

标签: iphone objective-c image


【解决方案1】:

像这样创建一个 UIImage:

UIImage *myImage = [UIImage imageNamed:@"image.jpeg"];

在 UIImageView 中显示它:

UIImageView *myImageView = [[UIImageView alloc] initWithImage:myImage];

并将 UIImageView 作为子视图添加到您现有的视图中:

[view adsdSubview:myImageView];

【讨论】:

【解决方案2】:

您可以使用以下代码显示来自 URL 的图像

NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:@"yourURL"]];

UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 250, 250)];
imgView.image=[UIImage imageWithData:imageData];
[self.view addSubview:imgView];

【讨论】:

    猜你喜欢
    • 2013-07-09
    • 2010-09-29
    • 1970-01-01
    • 1970-01-01
    • 2021-12-17
    • 2022-06-14
    • 1970-01-01
    • 1970-01-01
    • 2016-03-24
    相关资源
    最近更新 更多