我在我的电子邮件应用程序中展示 MFMailComposeViewController。但是视图没有得到显示,只显示上部的 SEND 和 CANCEL 按钮。
这是单击“发送电子邮件至订阅”按钮后显示的视图屏幕截图。
我已经检查了所有相关的代码。我添加了“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];
self.navigationItem.title=@"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:@"info@xyz.com", 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 =@"You have canceled your email.";
break;
case MFMailComposeResultFailed:
message=@"Your email is failed";
break;
case MFMailComposeResultSent:
message=@"Your email was successfully sent.";
break;
case MFMailComposeResultSaved:
message=@" Your email has been saved";
break;
default:
message=@" 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];
}
我无法得到这个问题的原因。
谢谢。