其實我想通了,如何做到這一點。 這有點像一個技巧,但它的工作原理。 所有你需要做的是落實委託的方法,像這樣
- (void) documentInteractionController: (UIDocumentInteractionController *) controller willBeginSendingToApplication: (NSString *) application {
BOOL isAppAllowed = YES;
// Make a decision based on app bundle identifier whether to open it or not
if (isAppAllowed) {
dispatch_async(dispatch_get_main_queue(), ^{
[self showRejectionMessage];
});
[self stopSendingFileUsingDocController:controller toApplication:application];
}
}
和我們欺騙代不良網址的文檔控制的實際方法。
-(void)stopSendingFileUsingDocController:(UIDocumentInteractionController *)controller toApplication:(NSString *)application
{
NSURL *documentURL = controller.URL;
NSString *filePath = [documentURL path];
filePath = [filePath stringByDeletingLastPathComponent];
NSString *filename = [filePath lastPathComponent];
NSMutableString *carets = [NSMutableString string];
for (NSUInteger i = 0; i < [filename length]; i++)
{
[carets appendString:@"^"];
}
#ifndef __clang_analyzer__
filePath = [filePath stringByAppendingPathComponent:carets];
NSURL *newURL = [[NSURL alloc] initFileURLWithPath:filePath];
controller.URL = newURL;
#endif
[self documentInteractionController:controller didEndSendingToApplication:application];
}
你是什麼意思「創建黑白名單」?不,你不能過濾應用程序列表。它基於共享文檔的UTI。 – rmaddy 2014-09-03 15:51:32
這意味着用戶可以阻止某些應用在列表中顯示。建議的應用程序的順序是由白名單(來自白名單的應用程序首先)來管理的,希望你明白我在說什麼。 – Stas 2014-09-04 08:33:49