以下のようにしているのですが、ログを取ると必ず画像が添付できなかったと返ってきます。ここで何が問題なのですか?
- (void)showInvitation {
if (![MFMessageComposeViewController canSendText]) {
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support SMS!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[warningAlert show];
return;
}
NSString *message = [NSString stringWithFormat:@"Download this game!"];
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
[messageController setBody:message];
if ([MFMessageComposeViewController canSendAttachments]) {
NSLog(@"Attachments Can Be Sent.");
NSData *imgData = [NSData dataWithContentsOfFile:@"water"];
BOOL didAttachImage = [messageController addAttachmentData:imgData typeIdentifier:(NSString *)kUTTypePNG filename:@"image.png"];
if (didAttachImage) {
NSLog(@"Image Attached.");
} else {
NSLog(@"Image Could Not Be Attached.");
}
}
[self presentViewController:messageController animated:YES completion:nil];
}