2014-10-24 2 views
8

base64 이미지를 포함하는 html 문자열을 생성합니다. MFMailComposeViewController가 열리면 생성 된 이메일에 이미지가 표시됩니다. 보내고 열면 이미지가 표시되지 않고 빈 사각형 만 표시됩니다.Ios에서 html 전자 메일로 base64 이미지 표시

내 코드

- (IBAction)actionShareByEmail:(id)sender { 

    if([MFMailComposeViewController canSendMail]) 
    { 
     MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
     picker.mailComposeDelegate = self; 

     NSString* subject = @"Environments list with qrcode"; 
     [picker setSubject:subject]; 
     [picker setMessageBody:[manager getHtmlWithEnvironments:nil] isHTML:YES]; 
     [self presentViewController:picker animated:YES completion:nil]; 
    } 
} 

-(NSString*)getHtmlWithEnvironments:(NSArray*)envDictionnaries{ 
    NSMutableString* html = [[NSMutableString alloc]init]; 
    [html appendString: @"<html><body>"]; 

    for (NSDictionary *d in self.arEnvironments) { 

     UIImage* qrcode = [QRCodeGenerator qrImageForString:[d objectForKey:@"env_name"] imageSize:200.0];//Works fine 
     NSData *imageData = UIImagePNGRepresentation(qrcode); 
     NSString *encodedString = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]; 
     [html appendString: [NSString stringWithFormat:@"<H3>%@</h3><img src=\"data:image/png;base64,%@\" width=\"200\" height=\"200\" alt=\"test\" /></br></br>",[d objectForKey:KEY_ENV_NAME],encodedString]]; 
    } 
    [html appendString: @"</html><body>"]; 

    return html; 
} 

어떻게 제대로 이미지를 표시하기 위해 무엇을 할 수 있는가?

+0

는 당신이 열려있는 이메일을 볼거야? 시야? IO 메일? 웹 브라우저? Gmail? – Ruskin

+0

http://stackoverflow.com/questions/8836706/base64-html-embedded-images-not-showing-when-mailed의 가능한 중복 – Ruskin

답변

관련 문제