0

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!

4

2 に答える 2

1

これを試して

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.twitter.com/%@", username.text]]];
于 2010-05-31T17:53:36.553 に答える
0

URL が正しいかどうかを確認する

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

編集:誰かが私より速かったようです;)

于 2010-05-31T17:54:42.510 に答える