Answer the question
In order to leave comments, you need to log in
iPhone development, UIWebView?
In Safari for iPhone, if you make a long-touch on the link, then an ActionSheet will appear with buttons - "Open", "Copy", "On a new page".
If you long-touch on the link in UIWebView, then only “Open”, “Copy” will appear.
Question: how to make UIWebView behave like in Safari? For example, add a button "On a new page"?
Answer the question
In order to leave comments, you need to log in
The first thing that came to my mind:
UIWebView inherits from UIView, so you can safely add a long press gesture handler.
Further, when the user clicks on the link, you receive a message about the triggering of this event. Set the flag that the user used the longpress event. After releasing your finger, you will receive an event.
— (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
Cancel the opening of the link (i.e. return return NO;)
At the same time, display a popup with a suggestion of actions. The only problem is determining the place where the popup should be displayed, but I can assume that the position of the link is determined using js
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question