2011-05-17 101 views
0

我有警告,下面的錯誤消息。請幫忙。需要郵件編輯器幫助xcode

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

} 

回答

1

問題是因爲錯誤說:你MyViewController類不符合MFMailComposeViewControllerDelegate協議。你的接口線應該是這個樣子:

@interface MyViewController : UIViewController <MFMailComposeViewControllerDelegate> 

,當然,你應該確保在你的類實現mailComposeController:didFinishWithResult:error:

+0

幹得好的男人。謝謝。警告消失了。 – Noob 2011-05-17 02:48:48