Is it possible to use a "mailto" button in a native iOS HTML page?
I have an IOS app that displays some hardcoded HTML开发者_开发技巧 pages... Is it possible to open the email program with a MailTo button ?
Yes, you can use mailto:
HTML links that work. It will most likely not work on the iOS Simulator. Try it on your device.
I just tried it using the below code, and the link was there, but the email App did not load when I clicked the link. Nothing at all happened in-fact. However, this was on the simulator.
Update: This did open the Mail App on an actual device. So, yes, it does work!
- (void)embedYouTubeWithVideoID:(NSString *)videoID {
CGFloat w = webView.frame.size.width;
CGFloat h = webView.frame.size.height;
NSString *ytUrlString = [NSString stringWithFormat:@"http://www.youtube.com/v/%@&version=3&autohide=1&autoplay=1&cc_load_policy=1&fs=1&hd=1&modestbranding=1&rel=0&showsearch=0", videoID];
NSString *embed = [NSString stringWithFormat:@"\
<html>\
<head>\
<meta name=\"viewport\" content=\"initial-scale = 1.0, user-scalable = no, width = %0.0f\"/>\
</head>\
<body style=\"background:transparent;margin-top:0px;margin-left:0px\">\
<div>\
<object width=\"%0.0f\" height=\"%0.0f\">\
<param name=\"movie\" value=\"%@\" />\
<param name=\"wmode\" value=\"transparent\" />\
<param name=\"allowFullScreen\" value=\"true\" />\
<param name=\"quality\" value=\"high\" />\
<embed src=\"%@\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" wmode=\"transparent\" width=\"%0.0f\" height=\"%0.0f\" />\
</object>\
</div>\
<a href=\"mailto:test@example.com\">MAIL_TO_TEST</a>\
</body>\
</html>", w, w, h, ytUrlString, ytUrlString, w, h];
[webView loadHTMLString:embed baseURL:nil];
}
精彩评论