私のアプリでは、ユーザーが Instagram 経由で写真を共有できるようにしています。これには、UIDocumentInteractionController の使用が必要です。電話が対応している場合、Airdrop は自動的に検出されます。この「開く」アクション シートから削除するにはどうすればよいですか?
UIActivityViewController で共有プロセスを開始して setExcludedActivityTypes: を呼び出しても、最終的には UIDocumentInteractionController を使用する必要があり、そうすると Airdrop が再び表示されます。共有ボタンがタップされたときのコードは次のとおりです。
NSURL *instagramURL = [NSURL URLWithString:@"instagram://location?id=1"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
NSString *documentsDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"Image.igo"];
NSData *imageData = UIImagePNGRepresentation(imageToShare);
[imageData writeToFile:savedImagePath atomically:YES];
NSURL *imageUrl = [NSURL fileURLWithPath:savedImagePath];
docController = [[UIDocumentInteractionController alloc] init];
docController.UTI = @"com.instagram.exclusivegram";
docController.URL = imageUrl;
[docController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
}
else
{
NSLog(@"no insta");
}