2012-08-28 49 views
0

打開我的設備上的其他應用程序要打開另一個應用程序(如GDrive的,的iBooks,等等)。使用我的應用程序中的UTI。我如何從我的應用程序

爲此,我使用下面的代碼從this site,其被用於從我的應用程序到另一個應用程序導出PDF文件嘗試。

NSString * filePath = [[NSBundle mainBundle] pathForResource:nil ofType:@"pdf"];  
documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:filePath]]; 
documentController.delegate = self; 
[documentController retain]; 
documentController.UTI = @"com.adobe.pdf"; 
[documentController presentOpenInMenuFromRect:CGRectZero inView:Parent animated:YES]; 

上面的代碼確實給我的應用程序(GDrive的,iBook筆記本等),我的設備上提供我的應用程序列表中,但是當我點擊這些應用程序中的任何一個,其出口從一個PDF我應用到選定的應用程序,但我已經使用的文件路徑爲「無」。

我想要做的是能夠從我的應用程序中打開我的設備上的任何其他應用程序(GDrive,iBooks等),而無需從我的應用程序向該其他應用程序發送任何PDF文件。

回答

1

自定義URL是要走的路。與實施轉寄此link示例代碼。

1

URL方案是要走的路,但當然不是每個應用都有它們。 可以找到一個完整的列表here(到這個答案的時候,該網站有某種錯誤,不會打開)。

如何使用他們打開Facebook的應用程序的一個例子:

NSURL *url = [NSURL URLWithString:@"fb://"]; 

if ([[UIApplication sharedApplication] canOpenURL:url]) 
{ 
    [[UIApplication sharedApplication] openURL:url]; 
} // else -> i.e. open Safari to Facebook's page or show an error message 
0

每一個應用程序由標識符這是在「com.companyName.appName」(EX的形式:「com.adobe。 APPNAME「)。 要在特定的應用程序中打開它,

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@「com.adobe.appname」]];

相關問題