2014-07-09 1 views
0

내가 JSON url.I에서 이미지를 얻고이 같은 노력 포맷하지만 난 내 생각을 NSData로 변환 첫째는 NSString 데이터입니다인코딩하는 방법을 이미지 base64로는

NSMutableArray *al=[NSJSONSerialization JSONObjectWithData:webData options:0 error:nil]; 
     NSLog(@"all NSMutable2%@",al); 
     NSDictionary *dict = [al objectAtIndex:1]; 
      NSString *title=[dict objectForKey:@"dealimage"]; 
      NSLog(@"all DIC%@",title); 

     NSData *data1 = [[NSData alloc] initWithData:[NSData 
                dataFromBase64String:title]]; 
      NSLog(@"********************************%@",data1); 
     NSData* data = [Base64 decode:title ]; 
     UIImage *image = [UIImage imageWithData:data]; 

     dig=[[UIImageView alloc]initWithImage:image]; 
     [self.view addSubview:dig]; 
     dig.frame = CGRectMake(0, 25 , 150,150); 

이미지하지 did't 다음에 전달을 NSData UIImage.But 아니 행운 그럼 제발 어떤 생각을주세요.

+0

로깅중인 데이터를 표시합니다. base64 디코딩이 두 번 있습니까? 당신이 base64를 요구하는 방법은 무엇입니까? – Wain

답변

1
#import "NSData+Base64.h" 

//Creating the data from your base64String 
NSData *data = [[NSData alloc] initWithData:[NSData dataFromBase64String: title]]; 

//Now data is decoded. You can convert them to UIImage 
UIImage *image = [UIImage imageWithData:data]; 

dig=[[UIImageView alloc]initWithImage:image]; 
dig.frame = CGRectMake(0, 25 , 150,150); 
[self.view addSubview:dig]; 
+0

당신은 2 번 디코딩되었는데, 그 유는 이미지에 들어갈 수 없다. –

+0

감사합니다. 한 가지 예가 2 번에 디코딩되었지만 UIImage에 단 하나의 NSdata를 전달했습니다. – chowdary

+0

이 줄을 쓴 후 U 데이터는 NSData * 데이터 = [Base64 디코드 : 타이틀]; –