I had a potential client ask me if I can prevent a user navigating away from their website within an iPad app? So I would need to load the client site within a web view and somehow disable invalid links i.e. banners and promotional links.
I am wondering if there is a way to catch the link that has been touched within the view before it is loaded.
If there is no way to do this, is there away to strip a web page of invalid links before it is loaded into the web view?
Use
UIWebViewDelegatemethodwebView:shouldStartLoadWithRequest:navigationType:. It’s called when user taps a link. ReturnNOif you don’t want to handle any links orYESif you want your web view to handle the request. More info in Apple docs.A nice thing is to filter out some requests and handle them yourself based on e.g. URL-scheme of the request or based on
UIWebViewNavigationTypevalue. Note: for a filtered requests that you handle, you still returnNO.