【发布时间】:2015-01-21 05:37:40
【问题描述】:
我已使用以下代码在 WhatsApp 上共享图像,但我无法使用以下代码设置标题文本。
我试过UIDocumentInteractionController的注解属性,但是在WhatsApp开发者表单中没有为注解指定任何键。
我知道我们可以使用UIImageGraphicContext 来做到这一点,但我需要分享 URL 作为标题
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]])
{
NSString * savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation([UIImage imageNamed:@"Convenor- image-SURANA1.png"], 1.0) writeToFile:savePath atomically:YES];
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
_documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"wwww.google.com" forKey:@"whatsappCaption"];
_documentInteractionController.UTI = @"net.whatsapp.image";
_documentInteractionController.delegate = self;
[_documentInteractionController presentOpenInMenuFromRect:CGRectMake(0, 0, 0, 0) inView:self.view animated: YES];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Alert." message:@"Por favor, instale Whatsapp." delegate:nil cancelButtonTitle:@"Está bem" otherButtonTitles:nil];
[alert show];
}
【问题讨论】:
-
我在WhatsApp FAQ for iOS developers 中看不到任何明显的内容。您可能需要email their product support at support@whatsapp.com。
-
谢谢,我已经邮寄给支持人员,但没有得到他们的回复。最后我做了一个技巧,我分享了一个带有文本的图像 url,所以图像将在该图像 url 路径中可用