我正在尝试在 twitter 中自动发布一个带有“#”字符的 url,如下所示:
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"]];
最佳答案
很可能是由于编码问题,请尝试使用 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];
关于iphone - '#' 字符 Twitter 在 ios 中发布 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8703282/