gpt4 book ai didi

ios - MFMailComposeViewController 的委托(delegate)未处理 'Cancel' 按钮或 iOS 4.x 及更早版本

转载 作者:行者123 更新时间:2023-11-28 20:31:28 24 4
gpt4 key购买 nike

我已经根据 Apple 提供的代码示例在我的应用程序中实现了标准邮件功能。我的代码如下

- (IBAction)mailBtnPressed:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
mailer = [[MFMailComposeViewController alloc] init];

[mailer setDelegate:self];

[mailer setSubject:@"Een berichtje via de iPhone app"]; mailer.mailComposeDelegate = self;
NSArray *toRecipients = [NSArray arrayWithObjects:@"studio@vrtfm.be", nil];
[mailer setToRecipients:toRecipients];

NSString *emailBody = @"";
[mailer setMessageBody:emailBody isHTML:NO];

[self presentModalViewController:mailer animated:YES];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oeps..."
message:@"Dit toestel ondersteunt geen mail functionaliteit."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued.");
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved: you saved the email message in the drafts folder.");
break;
case MFMailComposeResultSent:
NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send.");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error.");
break;
default:
NSLog(@"Mail not sent.");
break;
}
[self becomeFirstResponder];
// Remove the mail view
[self dismissModalViewControllerAnimated:YES];
}

点击“发送”按钮调用委托(delegate),一切正常。但是,点击“取消”按钮并不会调用委托(delegate),它只会使 View 变暗;该应用程序卡在那里。

注意事项: 我没有在我的应用程序中显示 StatusBar。

我没有使用 xib,而是代码 [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

此邮件功能在 iOS5、iOS5.1 上运行良好。但仅在较低版本中面临此问题。

我也尝试过使用 [mailer setMailComposeDelegate:self];

我当前的 xib 类大小为 (280,480)。

我在包含内容大小 (1540,960) 的 ScrollView 的单个 View 中使用多个 View 。

使用方法显示 View [scrollView scrollRectToVisible:frame animated:YES];

最佳答案

试试看这个example

简答:

尝试更改代码行

[mailer setDelegate:self];

mailer.mailComposeDelegate = self;

关于ios - MFMailComposeViewController 的委托(delegate)未处理 'Cancel' 按钮或 iOS 4.x 及更早版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12001796/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com