문제

I have this method

- (IBAction)facebookButtonPress:(id)sender {
    NSLog(@"fb hit");
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[@"www.facebook.com/asbreckenridge" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
}

and I don't understand why safari doesnt open the link. I get the 'fb hit' logged, so the method is being called, but it doesnt open the link in Safari, what am I doing wrong?

도움이 되었습니까?

해결책

Try it without the encoding like this.

- (IBAction)facebookButtonPress:(id)sender {
    NSLog(@"fb hit");
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.facebook.com/asbreckenridge"]];
}

Also try changing the URL to http://www.facebook.com/asbreckenridge

다른 팁

Try this:

- (IBAction)facebookButtonPress:(id)sender {
NSLog(@"fb hit");
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.facebook.com/asbreckenridge"]];
}

In my case problem was in extra "/" at the end.

doesn't work:
@"http://www.facebook.com/asbreckenridge/"

works fine:
@"http://www.facebook.com/asbreckenridge"

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top