Reputation: 6465
I am trying to append image in HTML and send it through mail in iOS 5 based iPhone. I am using following code:
UIImage *emailImage = [UIImage imageNamed:@"icon.png"];
NSData *imageData = UIImageJPEGRepresentation(emailImage, 0.6);
NSString *imageStr = [imageData base64EncodingWithLineLength:[imageData length]];
NSString *htmlStr = [NSString stringWithFormat:@"<img src='data:image/jpegbase64,%@'>",imageStr];
text=[text stringByAppendingString:htmlStr];
Its working perfect in iOS 4 but not in iOS 5. What is the reason behind and and how it can be resolved?
Upvotes: 0
Views: 654
Reputation: 437632
Aren't you missing a semicolon? E.g.,
NSString *htmlStr = [NSString stringWithFormat:@"<img src='data:image/jpeg;base64,%@'>",imageStr];
When you say it works in iOS 4 but not iOS 5, what do you mean? That it shows up ok in iOS 4 Mail, but not iOS 5 mail? Or that the app, for some reason, that generates the mail, somehow fails in iOS5? Can you be more specific about the behavior difference between iOS 4 and 5?
Upvotes: 1