Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restricting user interaction in UIWebView

Tags:

cocoa-touch

I want to restrict the users from using the links in a UIWebView. Hence, showing only single a HTML page with no navigation.

I know I can do that using the "User Interaction" option of UIWebView but I can't use that since it disables scrolling as well, and the user cannot view the complete page.

Any ideas?

like image 336
Mustafa Avatar asked Feb 05 '26 09:02

Mustafa


2 Answers

My situation demanded that a user really can ONLY look at the page, but not interact at all (specifically with respect to copying content--it was a security issue). Here's what I did:

for (UIView *thisView in webView.scrollView.subviews)
{
    thisView.userInteractionEnabled = NO;
}
like image 147
Herm Avatar answered Feb 12 '26 07:02

Herm


If you don't mind them seeing the links, you could use a UIWebViewDelegate to detect when a page begins loading and cancel it.

If you don't want them to see the links at all, you could modify the HTML before rendering it. Using libxml is pretty easy's and it's htmlparser.h can probably do what you need. If you don't like that, HTML tidy works well too.

like image 26
Gordon Wilson Avatar answered Feb 12 '26 09:02

Gordon Wilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!