0

I am trying to send an sms programmatically but I get the error no visible interface for presentModalViewController:completion: . The same code works with presentViewController but I need to display the sms dialog as a modal so it will return to my app. Any idea what I am missing ?

- (void) sendSMS:(NSString*)txtMsg photo:(UIImage*)image
{
    if (![MFMessageComposeViewController canSendText]) {

        UIAlertView *alertV = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device not support SMS" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alertV show];
        return;
   }

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

   mVC.body = txtMsg;
   mVC.messageComposeDelegate = self;

    if ([MFMessageComposeViewController canSendAttachments]) {
        NSLog(@"ok");
    }

    [mVC addAttachmentData: UIImagePNGRepresentation(image)   typeIdentifier:@"public.data" filename:@"image.png"];

    // This gives a compilation error
    [self presentModalViewController:mVC animated:YES completion:nil];

    // This compiles but gives the wrong behavior
    // [self presentViewController:mVC animated:YES completion:nil];

} 
Joel Parker
  • 295
  • 1
  • 4
  • 17
  • Check with this http://stackoverflow.com/a/27573491/3378413 – Mihir Oza May 08 '17 at 05:27
  • That post does not open it as a modal so when you hit send it doesn't call the delegate to close and return to the app. That is why I am asking specifically about presentModalViewController – Joel Parker May 08 '17 at 17:39

0 Answers0