を含む他のアプリへの共有イメージを開発していますWhatsApp
。私はこのコードを使用していますが、動作します。
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"whatsapp://app"]]){
UIImage *image = [self processImage:sender];
NSString *savePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/whatsAppTmp.wai"];
[UIImageJPEGRepresentation(image, 1.0) writeToFile:savePath atomically:YES];
_documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:savePath]];
_documentInteractionController.delegate = self;
_documentInteractionController.UTI = @"net.whatsapp.image";
[_documentInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}else {
[self showAlertTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed."];
}
問題は、このコードを実行すると、この画像documentInteractionController
のような他のオプション アプリが表示されるため、WhatsApp アプリケーションを開く前に、最初に WhatsApp を選択する必要があることです。
選択用のメニューを表示せずに、Whatsapp アプリを選択してファイルを共有できますか? 言い換えれば、私は避けることができpresentOpenInMenuFromRect
ますか?
iOS 9 を使用していますが、この問題は Instagram の投稿でも発生します