i am trying to open a url (http://c22.smaato.net/oapi/lp.jsp;jsessi开发者_Python百科onid=E253E547A55290CA553F493659433DBF.c22) on a button through the following code
NSString *strs=[[NSString alloc]initWithFormat:@"%@",[linkArry objectAtIndex:0]];
NSURL *urls = [NSURL URLWithString:strs];
[[UIApplication sharedApplication] openURL:urls];
[linkArry objectAtIndex:0] is the link mentioned above.
but it is not responding?? if i type something like "http://www.google.com" it works..
is there any other method to open these urls??
Check the line
NSURL *urls = [NSURL URLWithString:strs];
NSlog("urls : %@", urls); and print the urls in console , if you find urls is nil,
then escape the strs with NSUTF8StringEncoding.
strs = [strs stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *urls = [NSURL URLWithString:strs];
Make sure that url is of NSURL type and not NSString
精彩评论