ios - 尝试在文本字段的应用程序电子邮件中添加

标签 ios mfmailcomposeviewcontroller

它似乎有效,但我在我的 showEmailModalView 方法中收到编译警告: picker.mailComposeDelegate = self;它说“将 MyAppViewController *const_strong 传递给不兼容类型 'id 的参数”如果有人可以提供帮助,我将不胜感激。

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
    { 
        switch (result)
        {
            case MFMailComposeResultCancelled:
                break;
            case MFMailComposeResultSaved:
                break;
            case MFMailComposeResultSent:
                break;
            case MFMailComposeResultFailed:
                break;

            default:
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Email" message:@"Sending Failed - Unknown Error :-("
                                                               delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
                [alert show];

            }

                break;
        }
        [self dismissModalViewControllerAnimated:YES];
    }

-(void) showEmailModalView {

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    backUpTape = tapeDisplay.text;
    [picker setMessageBody:backUpTape isHTML:NO]; 

    picker.navigationBar.barStyle = UIBarStyleBlack; 

    [self presentModalViewController:picker animated:YES];
}

- (void) alertView: (UIAlertView *) alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        [pasteboard setValue:tapeDisplay.text forPasteboardType:@"public.utf8-plain-text"];
    } else if (buttonIndex == 2)
        [self showEmailModalView];

}

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView: self.view];

    if (CGRectContainsPoint(tapeDisplay.frame, location)) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Copy"
                                                        message: @""
                                                       delegate: self cancelButtonTitle: @"Cancel"
                                              otherButtonTitles: @"Copy", @"email", nil];
        [alert show];
    }

}

最佳答案

似乎有人不遵守 MFMailComposeViewControllerDelegate。将其放入一对 <>在 .h 文件中,看看当您再次构建并运行时错误是否消失。

关于ios - 尝试在文本字段的应用程序电子邮件中添加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9205261/

相关文章:

ios - 带有 mfmailcomposeviewcontroller 的空电子邮件...外语问题?

ios - swift 用户界面。如何设置 Spacer 的收缩行为?

javascript - Phonegap 中的解析查询返回错误 100 XMLHTTPRequest 失败

ios - UICollectionView 部分标题作为辅助功能标题

ios - 如何使用 Eureka 设计自定义 PickerInlineRow

html - 设置HTML正文时,MFMailComposeViewController在iOS5上崩溃

iOS希望在按下按钮时延迟 View Controller 之间的连接

swift - 使用 MFMailComposeViewController 发送电子邮件后关闭模态视图 Controller

ios - 将多个收件人添加到 MFMailcomposer torecepients : field - Xcode IOS

objective-c - MFMailComposerViewController 通过 UIActivityViewController 错误