I have a view controller which opens an MFMailComposeViewController modally. When I try to set the mail view controller's delegate to the parent view controller, I get this warning:
Assigning to 'id<UINavigationControllerDelegate>' from incompatible
type 'MoreViewController *__strong'
The parent view controller definitely has MFMailComposeViewControllerDelegate in its interface declaration and is implementing the delegate method -mailComposeController: didFinishWithResult:error:
as follows:
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
NSLog(@"Delegate called");
}
I really don't understand why the parent view controller is being recognized as a UINavigationControllerDelegate, as I don't implement those methods nor do I declare it as such. I wouldn't be so worried about it but the delegate method never gets called, so I'm guessing this "mismatch" is part of the problem.
If it helps, this is how I am initting the mail view controller, in viewDidLoad
:
// MAIL
self.mail = [[MFMailComposeViewController alloc] init];
self.mail.delegate = self;
Thanks in advance for any thoughts you may have.
You want to set mailComposeDelegate
rather than delegate
:
self.mail.mailComposeDelegate = self;
Basically, you were setting the delegate
which because MFMailComposeViewController
inherits from UINavigationController
, means that delegate
needs to implement UINavigationControllerDelegate
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With