我正试图在twitter中自动发布带有'#'字符的网址:
https://twitter.com/intent/tweet?related=palcomp3&text=Confira!!&url=http://palcomp3.com/avioesdoforro/#!/de-costa-mainha
然而,Twitter忽略了#
这是我尝试过的代码:
[webView setUrlAddress:[NSString stringWithString:@"https://twitter.com/intent/tweet?related=palcomp3&text=Confira!!&url=http://palcomp3.com/avioesdoforro/#!/de-costa-mainha"]];
和
[webView setUrlAddress:[NSString stringWithString:@"https://twitter.com/intent/tweet?related=palcomp3&text=Confira!!&url=http://palcomp3.com/avioesdoforro/%23!/de-costa-mainha"]];
答案 0 :(得分:3)
最有可能是由于编码,请尝试使用stringByAddingPercentEscapesUsingEncoding来获取URL安全字符串,并将其用作URL
NSString *str=[NSString stringWithString:@""https://twitter.com/intent/tweet?related=palcomp3&text=Confira!!&url=http://palcomp3.com/avioesdoforro/#!/de-costa-mainha"];
str=[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[webView setUrlAddress:str];