Reputation: 1040
I'm implementing a link in a UITextView, which will push a view controller on the navigation controller.
I'm trying to use the following method:
directionTextLabel.text = [directionTextLabel.text stringByAppendingString:[[NSString alloc] initWithFormat:@" %@", siteURL]];
directionTextLabel.dataDetectorTypes = UIDataDetectorTypeLink;
Which makes my link clickable. And then in my application delegate, I have:
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSLog(@"URL detected.");
return 1;
}
However, when I click on the link, it opens a new page without calling my app delegate method. Any idea what's going wrong, or other way I could implement that?
Thank you.
Upvotes: 1
Views: 2323
Reputation:
This method doesn't do what you think it does. This method gets called when your application is invoked by some URL scheme, and not when your app opens an URL.
Upvotes: 1
Reputation: 32597
The application:openURL...
delegate method is intended for when your application needs to respond to its registered URL handler(s) (as defined in your Info.plist file). The URL event will be sent to the similar method in the target application (for example Safari for http links).
EDIT: See this post
Upvotes: 1