문제

I can't understand why I must declare conformity to both MFMessageComposeViewControllerDelegate and UINavigationControllerDelegate when using MFMessageComposeViewController.

Failure to simply declare conformity to UINavigationControllerDelegate results in a compiler warning about assigning to 'id<UINavigationControllerDelegate>' from incompatible type ViewController *const __strong'

Why isn't declaring conformity to MFMessageComposeViewControllerDelegate and implementing the delegate methods in my header enough?

There aren't even any UINavigationControllerDelegate delegate methods to implement...

Relevant code...

Mmmmplementation:

-(void)shareTrainInformation
{
    NSLog(@"Sharing...");

    MFMessageComposeViewController *messageComposer = [[MFMessageComposeViewController alloc] init];

    messageComposer.delegate = self;

}

Header:

@interface RRDetailViewDrillDownViewController : UIViewController <MFMessageComposeViewControllerDelegate, UINavigationControllerDelegate>
도움이 되었습니까?

해결책

Use the composer's mailComposeDelegate property: composer.messageComposeDelegate = self;

It's because that name was already taken by an unrelated delegate declared in the superclass. (UINavigationController declares a delegate property.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top