2011-10-06 24 views
0

我有一個IOS應用程序,它顯示一些硬編碼的HTML頁面...是否可以使用MailTo按鈕打開電子郵件程序?是否可以在本機iOS HTML頁面中使用「mailto」按鈕?

+1

我相信與mailto:協議的任何鏈接打開郵件應用程序。當然,你可以試試這個。 –

+0

是啊..試過了,但沒有工作......我想知道是否有什麼特定的東西需要在iOS上做,以使其工作... – Nathan

回答

1

我剛剛嘗試使用下面的代碼,並且鏈接在那裏,但是當我單擊鏈接時,電子郵件應用程序未加載。事實上沒有任何事情發生。然而,這是在模擬器

更新:這確實打開了實際設備上的郵件應用程序。所以,是的,它確實有效!

- (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:[email protected]\">MAIL_TO_TEST</a>\ 
          </body>\ 
         </html>", w, w, h, ytUrlString, ytUrlString, w, h]; 
    [webView loadHTMLString:embed baseURL:nil]; 
} 

webview with mailto anchor tag

+0

啊,我只在模擬器中試過,感謝幫幫我 ! – Nathan

2

是的,你可以使用工作mailto: HTML鏈接。它很可能不適用於iOS模擬器。在您的設備上嘗試一下。

相關問題