2013-01-08 69 views
0

可能重複:
Can I open phone app using url scheme in iPhone如何在iPhone打開手機應用,而無需使用 「電話:// 123」 網址

在應用程序,我需要啓動手機應用程序。我不想撥打一個電話就如下面的代碼:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"tel://911\"]]; 

....這將只需撥打911,我想,如果我可以只啓動手機應用程序。我想這樣的代碼:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"tel://\"]]; 

但它亙古不變的工作

請幫我解決這個問題

回答

-2

試試這個代碼: -

NSString *prefix = (@"tel://123"); 
UIApplication *app = [UIApplication sharedApplication]; 
NSString *dialThis = [NSString stringWithFormat:@"%@", prefix]; 
NSURL *url = [NSURL URLWithString:dialThis]; 
[app openURL:url]; 

注意:電話號碼應該是有效的僅格式

希望它可以幫助你

+1

@downvote:爲什麼? –

+1

從問題:「在應用程序內,我需要啓動手機應用程序,我不想馬上撥打電話,就像代碼」問題已經在這裏解答http://stackoverflow.com/questions/3699471/can-i -open手機應用程序內,使用的URL的方案,在-iphone –

7

你不能那樣做。但是,如果您將tel:替換爲telprompt:,它將提示用戶確認呼叫。

編輯:此外,@"a string"NSString的語法文字。你不應該逃避報價。

相關問題