【问题标题】:images are displaying in simulator but not in device图像显示在模拟器中但不在设备中
【发布时间】:2014-01-03 13:47:52
【问题描述】:

我正在尝试从 url 加载图像,这些图像在模拟器中完美显示,但在 iphone 上却没有。关于可能是什么问题的任何想法? 这是代码

uiImageView = [[UIImageView alloc] initWithFrame:CGRectMake(40, iImageViewStart, 200, iImageHeight-50)];

uiImageView.contentMode = UIViewContentModeScaleAspectFit;
[self downloadImageWithURL:url completionBlock:^(BOOL succeeded, UIImage *image) {
        if (succeeded) {
            uiImageView.image = image;
        }
    }];
[scroll addSubview:uiImageView];

cellForRowAtIndexPath

`UIImageView *iconImage = [[UIImageView alloc] initWithFrame:CGRectMake(5,5, 40, 40)];`
    [self downloadImageWithURL:url completionBlock:^(BOOL succeeded, UIImage *image) {
        if (succeeded) {
            iconImage.image = image;
            tmpImage = image;
        }
    }];
//iconImage.image =tmpImage;
iconImage.layer.cornerRadius=20;
iconImage.backgroundColor=[UIColor blackColor];
iconImage.contentMode=UIViewContentModeScaleAspectFit;
[cell.contentView addSubview:iconImage];`

didSelectRowAtIndexPath

    FinalProdDisplay *FinalProdDisplayView = [ [FinalProdDisplay alloc] initWithNibName:@"FinalProdDisplay" bundle:nil];
Product *product = [ [Product alloc] init];
product= [arrayProducts objectAtIndex:[indexPath row]];
FinalProdDisplayView.strUrl=product.strProductImageUrl;

【问题讨论】:

  • 欢迎来到 SO。你试过什么?你能发布一些代码吗??
  • 对不起,我的水晶球昨天坏了....严重...您需要提供一些代码,没有人会帮助您只提供这些信息
  • 模拟器接受更广泛的图像格式。有时您有设备无法显示的特定文件类型。仔细检查文件格式。
  • 由于我们必须根据给定的有限信息进行猜测,您确定您的设备已连接到互联网吗?
  • @SibaPrasadHota 模拟器支持什么图像格式,而设备不支持?我使用了各种各样的图像类型(颜色空间、bpc、alpha 设置等)并且从未见过模拟器可以显示的图像,但设备不能(除了与图像无关的原因,例如大写、大小、连接性等)。

标签: ios objective-c uiimage


【解决方案1】:

请检查您的图片名称。 iOS 模拟器不区分大小写,而设备区分大小写。 因此,请仔细检查图像文件名。

【讨论】:

  • 图片来自 URL,所以我认为不会是这样。
  • @SibaPrasadHota 如果文件 URL,我认为这个问题仍然适用。如果它是一个引用服务器的 URL,那么你是对的,大写的不会改变设备和模拟器之间的行为。
【解决方案2】:

我检查了以 http:// .... 开头的服务器 URL。

我用 https 替换了 http,我在 iOS 应用程序中的图像开始显示。

【讨论】:

    猜你喜欢
    • 2012-06-24
    • 2011-05-28
    • 1970-01-01
    • 2013-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-03
    相关资源
    最近更新 更多