OGeek|极客世界-中国程序员成长平台

标题: iphone - 在 iPhone 上打开推文会导致 404 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:32
标题: iphone - 在 iPhone 上打开推文会导致 404

我正在开发一个 iPhone 应用程序,我在该应用程序中链接到本地​​ Twitter 应用程序中的特定 Twitter 推文。我尝试像这样打开 twitter 应用程序:

NSString *stringURL = [NSString stringWithFormat"twitter://status?status_id=%i", [self.tweetID intValue] ];
NSURL *url = [NSURL URLWithString:stringURL];
NSLog(@"Opening Twitter: %@", stringURL);
[[UIApplication sharedApplication] openURL:url];

但应用打开后显示“加载推文时出错 (404)”。我确认我使用的是与 twitter 网站相同的方案(右上角有一个按钮,可以在 iPhone twitter 应用程序中打开一条推文)。单击 twitter 网站上的链接可以正常工作,因此我在应用程序中的链接方式存在一些问题。

我能想到的只是问题的发生是因为我在我的 iPhone 上处于 Debug模式并且我的应用程序尚未发布或其他什么......但这看起来很奇怪。感谢您的帮助。



Best Answer-推荐答案


使用 intValue 可能会截断 tweetID。试试这个来创建你的 stringURL(假设 self.tweetID 是一个 NSString)。

NSString *stringURL = [NSString stringWithFormat"twitter://status?status_id=%@", self.tweetID];

关于iphone - 在 iPhone 上打开推文会导致 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16906835/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4