2013-01-23 65 views
5

我想通過我的應用程序發送電子郵件,和我使用下面的代碼:MailCompose與iPhone 5

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

      NSString *subject = @""; 
      NSString *body = @""; 

      [controller setSubject:subject]; 
      [controller setMessageBody:body isHTML:YES]; 

      [self presentModalViewController:controller animated:YES]; 

     } else { 
      NSString *message = @"Error opening mail, please make sure you have an email account setup"; 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops" message:message delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; 
      [alert show]; 
     } 

我發現了一個奇怪的錯誤,其中在我的iPhone 5,撰寫屏幕彈出,沒有身體(雖然身體設置在上面)。我「米沒能看到光標,如果我點擊任何框,因此不能編輯和發送按鈕是不可點擊當我解僱屏幕,我得到如下:

_serviceViewControllerReady:error: Error Domain=_UIViewServiceErrorDomain Code=1 "The operation couldn’t be completed. (_UIViewServiceErrorDomain error 1.)" 

然而,當我在iPhone 4s,iPhone 4和模擬器上測試它時,它可以正常工作,我也在另一臺iPhone 5上測試了它,它工作正常,身體在那裏,我可以發送電子郵件等。

還有什麼我可能會丟失?我有郵件我的手機上相關的兩個電子郵件帳戶,所以因此canSendMail應該工作...

+0

我假設你有,但只是爲了確保:你最近重新啓動了你的iPhone嗎?另外,是否在其他應用程序中編寫郵件工作?如果您沒有考慮另外一個應用,可以下載並編譯[Apple's Sample](http://developer.apple.com/library/ios/#samplecode/MailComposer/Introduction/Intro.html) 。 – Mathew

+0

哇......你說得對。它不適用於其他應用程序(如Twitter)。當我重新啓動它時,它就起作用了。沒有線索......如果你在下面迴應,我會接受它。 – KVISH

回答

13

嘗試使用compos其他應用程序中的對話框。如果您沒有考慮其他應用程序,可以下載並編譯Apple's Sample。如果它不適用於其他應用程序,請嘗試重新啓動您的設備。

+1

每隔一段時間,似乎我需要有人告訴我關掉它,然後再打開。謝謝,這讓我瘋狂了! – enjayem

+1

重新啓動爲我工作。 –

+1

重啓也適用於我。謝謝 – Lubbo