如何在没有图像时隐藏UIImageView的视图

时间:2014-08-05 08:21:14

标签: ios url uiimageview

我有一个UIImageView,其中image加载了url。我的问题是,当网址为empty时,视图会显示填充屏幕空间而没有任何内容。

我想知道如何隐藏此视图是url为空的字符串。

2 个答案:

答案 0 :(得分:1)

请检查:

NSString *URL = [YourURL absoluteString];

if(![URL isEqualToString:@"null"])
{
   imageView.image=@"img.png";
}

答案 1 :(得分:1)

您可以检查返回的URL字符串的长度,以确定它是否为空

NSString *yourURL

if ([yourUrl length]<1){

imageView.hidden = YES;

}else{

//show imageview with the image

}

我希望这会有所帮助