开发者

not able to open a url with openURL in [UIApplication sharedApplication]?

开发者 https://www.devze.com 2023-01-05 06:42 出处:网络
i am trying to open a url (http://c22.smaato.net/oapi/lp.jsp;jsessi开发者_Python百科onid=E253E547A55290CA553F493659433DBF.c22)

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

0

精彩评论

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