如何正确加载到imageview的网址链接以及如何在缓存中管理图片?

时间:2015-08-26 05:27:05

标签: ios objective-c uiimageview nsdate nsurl

NSString *img=[arrImages objectAtIndex:i];
imgScrollView.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:img]]];

我已经显示了我的代码。 URL链接已存储到数组中,图像也会被提取到uiimage视图中,但只有前两个图像被加载到imageview中,而其他图像没有加载。

arrImages:

内部图片viewhttp:// localhost:8888 / welcome / company / 0 / images / TV Repair.png

这是arrImages中存在的链接我不知道为什么前两个图像已经加载。

FOR LOOP:

    for(NSDictionary *DicHoleCategories in ArrCategory)
    {
        StrName=[DicHoleCategories objectForKey:@"image"];
        if(StrName!=nil)
        {
            subimages=[NSString stringWithFormat:LocalImage"%@",StrName];
            [DicAllValues setObject:subimages forKey:@"image"];
            NSError *error =nil;
        }
        [arrImages addObject:[DicAllValues objectForKey:@"image"]];
    }

有人能找到问题并帮助我吗?

2 个答案:

答案 0 :(得分:0)

请按照以下代码

    if(StrName!=nil)
    {
        subimages=[NSString stringWithFormat:LocalImage"%@",StrName];
        [DicAllValues setObject:subimages forKey:@"image"];
        NSError *error =nil;
        [arrImages addObject:[DicAllValues objectForKey:@"image"]];//add here!

    }

现在检查并告诉我它是否正常工作!

答案 1 :(得分:0)

完成以下编码

if username == "" || < 5 {
    session.AddFlash("Username is too short")
    session.Save(r, w)
}