【发布时间】:2014-06-03 18:16:17
【问题描述】:
我正在执行以下操作,但是在记录时,它总是返回无法附加图像。这里有什么问题?
- (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];
}
【问题讨论】:
-
什么账号?也许您的 ISP 阻止了彩信?尝试使用 iMessage。
-
它确实说当我将其登录到控制台时可以发送附件。如何尝试使用 imessage?
-
实际上是的,我正在使用 iMessage。
-
为什么不将附件添加为文件?您已经在磁盘上拥有它,创建一个
NSURL并使用其他方法。 -
哇!这实际上最终起作用了!谢谢!!!
标签: objective-c ios7 uiimage mfmessagecomposeview messageui