【发布时间】:2016-04-11 13:14:08
【问题描述】:
我使用此代码从我的 iOS 应用程序在 Whatsapp 上共享图像,但控制器始终处于 else 状态。请给我一个解决方案。
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]])
{
UIImage *iconImage = [UIImage imageNamed:dict23[@"profileimg"]];
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation(iconImage, 1.0) writeToFile:savePath atomically:YES];
documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
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:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
【问题讨论】:
标签: ios objective-c iphone ios7