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

时间:2012-02-09 04:03:24

标签: 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];
    }

}

1 个答案:

答案 0 :(得分:1)

看起来有人不符合MFMailComposeViewControllerDelegate。将它放在.h文件中的一对<>中,看看在构建并再次运行时错误是否消失。