NSAttributedString & Peek and Pop

Hey,


I'm using UITextView with NSAttributedString to show links, which automatically makes the links peek and pop, which is great!

What I'm struggling with is finding a way to pop in to an SFSafariViewController instead of popping into Safari.app.


Is there any way to pop into a custom view (or just SFSafariViewController) or do I have to implement peek and pop myself to get that?


Thanks!

I'm going to go out on a limb and say that this is not possible. There is nothing that can be changed or registered to to change this behaviour.

How are you using the attributed string. Is it being displayed in a UITextView?


IDid you try the delegate method:


- (BOOL)textView:(UITextView *)textViewshouldInteractWithURL:(NSURL *)URL        inRange:(NSRange)characterRange

The docs:

The text view calls this method if the user taps or long-presses the URL link. Implementation of this method is optional. By default, the text view opens the application responsible for handling the URL type and passes it the URL. You can use this method to trigger an alternative action, such as displaying the web content at the URL in a web view within the current application.

Yeah, this method does not get fired if the user hard-presses the links. So even returning false here won't really help for anything other than making links useless.

Hmmm. so you're saying it gets fired on when it touches down, but you want to respond to hard presses??


You should be able to do it right there, if all you want to do is show a web view when the link is tapped:


- (BOOL)textView:(UITextView *)textViewshouldInteractWithURL:(NSURL*)URL        inRange:(NSRange)charRange
{
    
SFSafariViewController *safariViewController = [[SFSafariViewController alloc]initWithURL:URL];
            safariViewController.delegate = self;
            [self presentViewController:safariViewController animated:YES completion:nil];


    return NO;

}


I haven't used this in awhile.

NSAttributedString & Peek and Pop
 
 
Q