openURL 中的多个字符串。 iPhone SDK

发布于 2024-09-03 10:55:46 字数 305 浏览 9 评论 0原文

我正在为 iPhone 制作一个 twitter 应用程序,我正在尝试添加一个按钮来打开 Safari,并将用户带到他们的 twitter 主页。我有一个名为用户名的文本字段,因此以下代码不起作用,希望有人能够帮助我。

-(IBAction)viewAccount {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.twitter.com/", username.text]];

}

任何帮助表示赞赏!谢谢你!

I am making a twitter application for iPhone, I am trying to add a button which will open Safari, and take the user to their twitter homepage. I have a textfield called username, so the following code does not work, hopefully someone will be able to help me out.

-(IBAction)viewAccount {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.twitter.com/", username.text]];

}

Any help is appreciated! Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

聽兲甴掵 2024-09-10 10:55:46

试试这个

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.twitter.com/%@", username.text]]];

Try this

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.twitter.com/%@", username.text]]];
高跟鞋的旋律 2024-09-10 10:55:46

检查您的网址是否正确

NSURL* twitterURL = [NSURL URLWithString:@"http://www.twitter.com/", username.text];
NSLog(@"my twitter url: %@", twitterURL);

编辑:似乎有人比我更快;)

Check if your URL is correct

NSURL* twitterURL = [NSURL URLWithString:@"http://www.twitter.com/", username.text];
NSLog(@"my twitter url: %@", twitterURL);

edit: seems someone was faster than me ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文