开发者

Monotouch stringWithFormat using a URL

开发者 https://www.devze.com 2022-12-24 11:11 出处:网络
I开发者_如何学C\'m trying to learn the MapKit with Monotouch and I\'m having difficulty figuring out how to search for an address.I finally found this snippet of Objective-C code that might help but i

I开发者_如何学C'm trying to learn the MapKit with Monotouch and I'm having difficulty figuring out how to search for an address. I finally found this snippet of Objective-C code that might help but it has a line where they use a URL to get a return value and I have no idea how to use this code in C#:

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

If anyone could give me some advice that would be helpful.


This is equivalent to:

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


For urls try this

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

精彩评论

暂无评论...
验证码 换一张
取 消