我在我的電子郵件應用程序中呈現MFMailComposeViewController。 但是這個視圖並沒有顯示出來,只有上層的SEND和CANCEL按鈕才顯示出來。MFMailComposeViewController模型不顯示
這是點擊「電子郵件訂閱」按鈕後顯示的視圖的屏幕截圖。
我已簽出所有相關的代碼。我已經加入「MessageUI」框架和進口
MessageUI/MessageUI.h , MessageUI/MFMailComposeViewController.h
我用下面的代碼:
- (void)viewWillAppear:(BOOL)animated {
[self.view setFrame:CGRectMake(0, 62, 320, 418)];
[APPDELEGATE.window addSubview:self.view];
[self.navigationController.navigationBar setHidden:NO];
[email protected]"Free Subscription";
[super viewWillAppear:animated]; }
-(void)viewWillDisappear:(BOOL)animated {
[self.view removeFromSuperview];
[super viewWillDisappear:animated]; }
-(IBAction)btnEmailPressed {
MFMailComposeViewController* Apicker = [[MFMailComposeViewController alloc] init];
if (Apicker != nil)
{
[Apicker setSubject:@"Free Subscription"];
[Apicker setMessageBody:@" " isHTML:NO];
NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", nil];
[Apicker setToRecipients:toRecipients];
Apicker.mailComposeDelegate = self;
if([MFMailComposeViewController canSendMail])
{
[self presentModalViewController:Apicker animated:YES];
}
else
{
}
[Apicker release];
} }
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError
*)error{
NSString *message;
switch (result) {
case MFMailComposeResultCancelled:
message [email protected]"You have canceled your email.";
break;
case MFMailComposeResultFailed:
[email protected]"Your email is failed";
break;
case MFMailComposeResultSent:
[email protected]"Your email was successfully sent.";
break;
case MFMailComposeResultSaved:
[email protected]" Your email has been saved";
break;
default:
[email protected]" Your email is not send";
break;
}
UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"" message:message delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alt show];
[alt release];
[self dismissModalViewControllerAnimated:YES];
}
我無法得到這個問題的原因。
謝謝。
你的MailComposeViewController添加委託? –
@PuneethSB - 亞我已添加它 –
我將粘貼正在爲我工作的代碼 –