2016-07-12 6 views
-3

Ich erhielt folgende Antwort von JSON:Objective-C - Wie setze ich ein Bild von JSON in UIImageView?

{ 
    age = 42; 
    city = Berlin; 
    country = Deutschland; 
    distance = "4.58"; 
    "full_name" = Klaus; 
    gender = Male; 
    id = 654; 
    online = 0; 
    profile = "Klaus.png"; 
}) 

ich den folgenden Code unter Verwendung des Bildes in der UIImageView zu ändern.

NSString *imageURL = [[_responsedic valueForKey:@"profile"]objectAtIndex:0]; 

_TopList_ImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]]; 

Ich wünsche den Profilwert aus dem JSON in den UIImageView setzen, aber der Code tat nichts. Schätze jede Hilfe, danke im Voraus.

+1

Ihr Profilbild Pfad fehlt ... es sollte wie http: //www.*****.com/yourimage.png –

+0

ungültige Bild URL sein. es sollte sein: www.apple.com/de/home/iphone.png –

+0

Sie müssen Online-Link zu Bild wie www.asd.com/images/Klaus.png haben, nachdem Sie es problemlos –

Antwort

0

self.imageView.image = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: Ihre URL]]];

1

versuchen, dies ..

NSString *imgURL = @"imagUrl"; 
     NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:imgURL]]; 

    //set your image on main thread. 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [YourImgView setImage:[UIImage imageWithData:data]]; 
    });  
}); 
+0

yeah. thnx das funktioniert –

+0

@BajrangSinha Happy coding .. Bitte akzeptieren Sie meine Antwort .. –