-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *) elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName{
if ([elementName isEqual:@"image"]) {
NSLog(@"Encoded Data %@",encodedData); //THIS SHOWS UP FINE
//lets now show image
UIImage * decodedImage = [[UIImage alloc] initWithData:[Base64 decode:encodedData]];
[Image setImage:decodedImage]; //WHERE IS THE IMAGE?
[encodedData release];
encodedData = nil;
}
}
我正在使用以下库进行base 64解码。
http://imthi.com/blog/programming/iphone-sdk-base64-encode-decode.php
最佳答案
-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *) elementName
namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName {
if ([elementName isEqual:@"image"]) {
NSLog(@"Encoded Data %@",encodedData); //THIS SHOWS UP FINE
//lets now show image
UIImage * decodedImage = [[UIImage alloc] initWithData:[Base64 decode:encodedData]];
[yourImageView setImage:decodedImage]; //WHERE IS THE IMAGE?
//Make sure that you have the imageView added as subview to your current view.
[encodedData release];
encodedData = nil;
[decodedImage release];
}
}