2016-09-16 128 views
2

我遵循完全相同的教程Launch an app from within another (iPhone),但代碼僅執行else部分並顯示警報,所以我無法打開第二個應用程序。您可以在上面的鏈接中看到我所遵循的步驟。無法從另一個(iPhone)內啓動應用程序

讓我們假設我們有兩個應用程序稱爲FirstApp和SecondApp。當我們打開FirstApp時,我們希望能夠通過單擊按鈕打開SecondApp。要做到這一點的解決方案是:

在SecondApp

轉到SecondApp的plist文件,你需要添加一個URL計劃用字符串iOSDevTips(當然你也可以另寫string.it的由你) 。

2。在FirstApp

與下方的操作創建一個按鈕:

- (void)buttonPressed:(UIButton *)button 
{ 
    NSString *customURL = @"iOSDevTips://"; 

    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:customURL]]) 
    { 
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]]; 
    } 
    else 
    { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"URL error" 
           message:[NSString stringWithFormat:@"No custom URL defined for %@", customURL] 
           delegate:self cancelButtonTitle:@"Ok" 
           otherButtonTitles:nil]; 
    [alert show]; 
    } 

} 

回答

4

添加自定義網址中的info.plist

第一圖象 - 在您的應用程序,你要打開

第二次圖像 - 在你的應用程序中,你正在打開

In Your App which you are opening

In Your App which from you are opening

爲了充分說明和代碼訪問我的博客here

+0

我正在打開從第一個應用程序的第二應用程序...但我沒有得到你的觀點「在您的應用程序,從您打開」是指我有設置在其中第二圖像 – virat

+0

我不想發送文本中顯示的第一個應用程序的性能只是想打開應用程序 – virat

+0

呀第一圖像的參考是其中yoou試圖打開的應用程序。只要定義一個URL Scheme就可以了。第二個圖像是用於打開另一個應用程序的應用程序。在這裏,您必須使用相同的字符串名稱來定義QueryScheme。 – Nilesh

相關問題