在我的应用程序中,我在共享表中实现了一个名为 Open In 的自定义活动,点击此图标将生成一个 .txt 文件并显示能够打开和使用此生成的 .txt 文件的应用程序列表。iOS 会自动在共享表中每个应用程序的名称前添加“打开方式”。
但是现在第三方开发人员已经实现了共享扩展,出于某种原因,这些扩展也出现在了这个 Open In 界面中。例如,Twitter 出现了,但是当我点击它时,.txt 文件中的文本不会出现在撰写窗口中。因此,这些第三方共享扩展在这个界面中是完全没用的。另外,它们已经出现在原始共享表中(并且它们在那里工作) - 用户点击了打开方式,因此他们只关心可以打开 .txt 文件的应用程序。
如何确保在此自定义活动中仅提供 Open In 应用程序?
//make a txt file to write the data
NSString *fileName = [NSString stringWithFormat:@"%@Text.txt", NSTemporaryDirectory()];
[self.textToShare writeToFile:fileName
atomically:NO
encoding:NSUTF8StringEncoding
error:nil];
NSURL *textFileURL = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent:@"Text.txt"]];
self.openInController = [UIDocumentInteractionController interactionControllerWithURL:textFileURL];
self.openInController.delegate = self;
BOOL didPresentOpenIn = [self.openInController presentOpenInMenuFromBarButtonItem:self.buttonToPresentFrom animated:YES];
if (!didPresentOpenIn) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Apps Available"
message:@"You do not have any apps installed that can open text files."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}