我发出警告,上面有错误消息。请帮忙。
Assigning to 'id<MFMailComposeViewControllerDeelegate>' from incompatible type 'MyViewController'
和
Class 'MyViewController' does not implement the 'MFMailComposeViewControllerDelegate' protocol
代码是
-(void)displayComposerSheet
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
//below bold code is warning
**picker.mailComposeDelegate = self;**
[picker setSubject:@"My first apps!"];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObjects: nil];
[picker setToRecipients:toRecipients];
[picker setMessageBody:TextView.text isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
答案 0 :(得分:1)
问题出在错误上:您的班级MyViewController
不符合MFMailComposeViewControllerDelegate
协议。您的界面行应如下所示:
@interface MyViewController : UIViewController <MFMailComposeViewControllerDelegate>
当然,您应该确保在班上实施mailComposeController:didFinishWithResult:error:
。