2016-10-12 53 views

回答

0

嘗試此。

if ([imageUrl isKindOfClass:[NSString class]]) { 
        [_profileImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"PlaceHoldeImage"]]; 


    }else{ 
     _profileImageView.image=[UIImage imageNamed:@"PlaceHoldeImage"]; 


    } 
+0

if([imageUrl isKindOfClass:[NSNull class]]){ _profileImageView.image = [UIImage imageNamed:@「PlaceHoldeImage」]; } –

+0

現在確定這是工作.. –

+0

@chunchu swamy,你的代碼開始工作? –

0
NSString *imageUrl= [ProfileArray valueForKey:@"photo"]; 

if ([imageUrl isKindOfClass:[NSNull class]]) 
{ 
    _profileImageView.image=[UIImage imageNamed:@"PlaceHoldeImage"]; 
} 
else 
{      
    [_profileImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"PlaceHoldeImage"]]; 
} 
_profileImageView.image=[UIImage imageNamed:@"PlaceHoldeImage"]; 
0

使用此代碼。它應該肯定有效。

NSString *imageUrl= [ProfileArray valueForKey:@"photo"]; 
    if ([imageUrl isKindOfClass:[NSNull class]]) { 
     _profileImageView.image=[UIImage imageNamed:@"PlaceHoldeImage"]; 
    } else { 
     [_profileImageView sd_setImageWithURL:[NSURL URLWithString:imageUrl] placeholderImage:[UIImage imageNamed:@"PlaceHoldeImage"]]; 
    } 
0

試試看看這個代碼。

NSString *imageUrlString= [photoDict valueForKey:@"photo"]; 
if (imageUrl.length == 0) 
{ 
    _profileImageView.image=[UIImage imageNamed:@"PlaceHoldeImage"]; 
} 
else 
{ 
    _profileImageView.image=[UIImage imageNamed:imageUrlString]; 
}