سؤال

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];
هل كانت مفيدة؟

المحلول

I believe you issue is that your not sending in a base64 encoded string to initWithBase64EncodedString.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top