Я пытаюсь отправить смс программно, но получаю сообщение об ошибке: нет видимого интерфейса для presentModalViewController:completion: . Тот же код работает с presentViewController, но мне нужно отобразить диалоговое окно sms как модальное, чтобы оно вернулось в мое приложение. Любая идея, что мне не хватает?
- (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];
}