我在iOS应用中使用以下代码来使用Instagram iPhone挂钩将照片发布到Instagram。我只希望“打开方式...”菜单具有Instagram应用,没有其他应用。但就我而言,Camera +也出现了。如何限制Instagram?
另外,我可以直接打开Instagram而不显示“打开方式”菜单吗?
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
//imageToUpload is a file path with .ig file extension
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imageToUpload]];
self.documentInteractionController.UTI = @"com.instagram.photo";
self.documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"my caption" forKey:@"InstagramCaption"];
[self.documentInteractionController presentOpenInMenuFromBarButtonItem:self.exportBarButtonItem animated:YES];
}
最佳答案
仅回答第一个问题:您可能可以将“打开于...”菜单限制为仅显示设备的Instagram(例如,通过删除Camera + App),但是您将无法限制将您的应用安装到其设备的用户。这是因为iPhone识别出哪些应用程序能够打开特定类型的文件,并自动显示每个文件。