ios中的'#'字符Twitter帖子网址

时间:2012-01-02 16:49:08

标签: iphone ios url twitter

我正试图在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"]];

1 个答案:

答案 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];