2016-06-01 3 views
1

JSONファイルのデータ。JSONのUIImageView

jsonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; 
    NSString *cPhoto = [[jsonArray objectAtIndex:i] objectForKey:@"photo"]; 
       NSURL *urlOne = [NSURL URLWithString:cPhoto]; 

       NSData *photoData =[NSData dataWithContentsOfURL:urlOne]; 
       UIImage *imageOne = [[UIImage alloc] initWithData:photoData]; 

       NSLog(@"%@",imageOne); 

のNSLogビュー:

[10872:310156] (null) 
    [10872:310156] <UIImage: 0x7f97f25cd220>, {1005, 651} 
    [10872:310156] <UIImage: 0x7f97f25d59c0>, {1005, 651} 
    [10872:310156] (null) 
    [10872:310156] (null) 

のNSLogはショー* .JPGフォーマットしない理由? 。 * .pngファイル(2-ndと3-rd)のみ。 ありがとう、非常に私の悪い英語を許してください!

+1

がphotoData'が有効な '問題の原因1です以下の答えをお試しください! URLは有効ですか? – Larme

+0

@Larmeはい、もちろんです。写真はデータ型番号、名前、姓を取得します... –

+0

'UIImage'がnilの場合、' photoData'もnullですか? – Larme

答えて

0

UIImage* imageOne = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString:cPhoto]]]; 
+0

1行に3行ありがとうございます。それはどうやって問題を解決するのですか? – Larme

+0

それは間違いなくあなたを助けます。 – user3182143

+0

最初にこのコーディングを適用してください。 – user3182143