I believe you issue is that your not sending in a base64 encoded string to initWithBase64EncodedString
.
Objective-c Base64 NSString to NSData conversion
-
13-10-2022 - |
题
I am trying to load in a very large string that is a base64 encoded PNG into NSData
to create a UIImage
on the fly. I can get the image generated by it is very distorted. Am I doing this correctly? I am also using SBJson in this example.
// Data is the NSData loaded in from the web
NSString *responseValue = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSString *successData = [(NSDictionary*)[responseValue JSONValue] objectForKey:@"MapFlightResult"];
NSData *pngData = [[NSData alloc] initWithBase64EncodedString:successData options:1];
UIImage *map = [UIImage imageWithData:mapData];
[imageView setImage:map];
解决方案
不隶属于 StackOverflow