2012-08-09 87 views

回答

6

你必須弄清楚的行動。但這裏有一個例子:

yourAppURL://doSomething 

yourAppURL://doAnotherThing 

,然後在AppDelegate

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { 
    NSString *text = [[url host] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    if ([text isEqualToString:@"doSomething"]) { 
     // then do something 
    } 
    if ([text isEqualToString:@"doAnotherThing"]) { 
     // do another thing 
    } 
} 

你可能通過在URL中發送各種文本來做各種各樣的東西。例如,Facebook使用它來打開應用程序直接轉到個人檔案facebook://profile=username

+0

感謝代碼完美工作! – atomikpanda 2012-08-10 00:36:13

+0

這很好聽:) – runmad 2012-08-10 02:55:51