Reputation: 49
I am very new to implement delegate methods. I am implementing sms application. I am able to open the sms delegate method and seen the TO and Send options but when I try to came back to main it is not working my code is as follows, please help me.
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
message.hidden = NO;
switch (result)
{
case MessageComposeResultCancelled:
message.text = @"Result: canceled";
NSLog(@"Result: canceled");
break;
case MessageComposeResultSent:
message.text = @"Result: sent";
NSLog(@"Result: sent");
break;
case MessageComposeResultFailed:
message.text = @"Result: failed";
NSLog(@"Result: failed");
break;
default:
message.text = @"Result: not sent";
NSLog(@"Result: not sent");
break;
}
[self dismissModalViewControllerAnimated:YES];
}
Upvotes: 2
Views: 2729
Reputation: 90117
my guess is that this code doesn't get called because you forgot to assign the delegate of the MFMessageComposeViewController.
look in the part of your code where you create the messagecomposer and see if there is a call like this: picker.messageComposeDelegate = self;
If it's not there you have to add it. Otherwise the composer can't call your delegate function.
Upvotes: 13