2012-07-02 24 views
-1

我有一個iPad應用程序,由加載第二個視圖控制器的根視圖控制器組成。在第二個視圖控制器中,我有一個按鈕應該顯示MFMailComposeViewController爲什麼試圖在這裏呈現一個MFMailComposeViewController鎖定屏幕?

我的問題是:
在模擬器上,這工作正常。但是,在實際設備上,按此按鈕鎖定屏幕,似乎禁用所有用戶與接口交互。

我的代碼是:

//************** Send Email using Default IM ************************ 
-(void) showEmailModalView 
{ 
    NSLog(@"Start method <ExportStatisticsController> : <showEmailModalView> --"); 


    // emailTextField.text = [emailTextField.text stringByReplacingOccurrencesOfString:@"(null)" withString:@""]; 
    // subjectTextField.text = [subjectTextField.text stringByReplacingOccurrencesOfString:@"(null)" withString:@""]; 
    // messageBodyTextView.text = [messageBodyTextView.text stringByReplacingOccurrencesOfString:@"(null)" withString:@""]; 

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; // &lt;- very important step if you want feedbacks on what the 
    //user did with your email sheet 

    [picker setSubject:@""]; 

    NSArray *torec=[[NSArray alloc] initWithObjects:@"[email protected]", nil]; 
    [picker setToRecipients:torec]; 
    [torec release]; 

//------ message body --- 

    NSString *body [email protected]""; 

    [picker setMessageBody:body isHTML:NO]; // depends. Mostly YES, unless you want to send it as plain text (boring) 

    picker.navigationBar.barStyle = UIBarStyleBlack; // choose your style, unfortunately, Translucent colors behave quirky. 
// picker.ModalTransitionStyle = UIModalTransitionStyleCrossDissolve; 

    [self presentModalViewController:picker animated:YES]; 
    [picker release]; 
    NSLog(@"End method <ExportStatisticsController> : <showEmailModalView> --"); 

} 

什麼可能我是做錯了引起畫面凍結這樣嗎?

+1

不知道什麼時候創建完全相同的問題,當前一個被關閉...什麼是 – Peres

+1

有許多拼寫錯誤和困惑words.so我試圖讓它更清楚。如果它比以前清楚,請告訴我。 –

+0

這是什麼操作系統? – prince

回答

0

設備可能未設置爲發送郵件。

在使用MFMailComposeViewController之前,您應該調用[MFMailComposeViewController canSendMail]以確保設備配置爲發送郵件。

在試圖將其作爲模態視圖控制器呈現之前,檢查picker變量是否爲非零也是一個好主意。

相關問題