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.
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