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

发布于 2025-01-04 01:13:41 字数 2371 浏览 0 评论 0原文

它似乎有效,但我在我的 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];
    }

}

It seems to be working but I am getting a compile warning inside of my showEmailModalView method on the line: picker.mailComposeDelegate = self; It says "Passing MyAppViewController *const_strong to parameter of incompatible type 'id" If anyone can help with this I will appreciate it.

- (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];
    }

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沦落红尘 2025-01-11 01:13:41

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

Looks like somebody isn't conforming to the MFMailComposeViewControllerDelegate. Put it in a pair of these <> in the .h file and see if the error goes away when you build and run again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文