简体   繁体   English

openURL中有多个字符串。 iPhone SDK

[英]Multiple strings in openURL. iPhone SDK

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. 我正在为iPhone开发一个Twitter应用程序,我试图添加一个按钮来打开Safari,并将用户带到其Twitter主页。 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! 谢谢!

尝试这个

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

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 ;) 编辑:似乎有人比我快;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM