2010-03-21 44 views
0

我正在嘗試使用Monotouch學習MapKit,我很難弄清楚如何搜索地址。我終於找到了Objective-C代碼這個片斷,可以幫助,但它有他們使用URL來獲取返回值的行,我不知道如何使用這個代碼在C#:使用URL的單點觸控stringWithFormat

NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", [addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

如果有人能給我一些有益的建議。

回答

4

這相當於:

string urlString = String.Format(@"http://maps.google.com/maps/geo?q={0}&output=csv", System.Web.HttpServerUtility.UrlEncode(addressField.text)) 
+0

哎呀,我貼的代碼,但由於錯誤的代碼段爲您正確的答案! :) – 2010-03-22 14:26:48

0

對於網址試試這個

var uri = new Uri (url); 
var nsurl = new NSUrl (uri.GetComponents (UriComponents.HttpRequestUrl, UriFormat.UriEscaped)); 
UIApplication.SharedApplication.OpenUrl (nsurl);