I have refered this but not working for me :How to intercept click on link in UITextView?
I have hyperlink text on UITextView, on click of the hyperlinked text we have to open another View Controller.
to create hyperlink I have done this
NSString *str = @"No products found for your pincode,Edit your pincode";
NSMutableAttributedString *aStr = [[NSMutableAttributedString alloc]initWithString:str attributes:nil];
[aStr addAttribute:NSLinkAttributeName value:@"https://www.google.com/" range:[str rangeOfString:@"Edit your pincode"]];
[self.myTextView setAttributedText:aStr];
to open AnotherViewController I used UITextView shouldInteractWithURL delegate method.
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction{
TATViewController *tatVC = [[self getStoryboardWithStoryboardType: kListingStoryboard] instantiateViewControllerWithIdentifier: @"TATViewControllerID"];
[self.navigationController presentViewController: tatVC animated:true completion:nil];
return false;
}
My question is how to manage TextView delegate code and hyperlink code to open a ViewController.