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