Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView - How to Disable Action Sheets (UIActionSheet)?

I would like to know how you can disable UIActionSheets, specifically the Action Sheets being displayed after tapping and holding hyperlinks in a UIWebView. These seem to be enabled by default in UIWebViews containing the link address of the respective link in the title of the alert. They are also enabled in Safari.

(How) is it possible to disable all Action Sheets of this kind within a UIWebView?

Thanks in advance!

like image 671
RodneyFarva Avatar asked May 11 '10 05:05

RodneyFarva


3 Answers

I just found this solution myself. Add this to your CSS:

body {
  -webkit-touch-callout: none;
}

To be clear, this disables the action sheet that appears when you hold down a hyperlink.

like image 178
Brian Avatar answered Nov 14 '22 09:11

Brian


You can also handle this via JavaScript by calling:

document.documentElement.style.webkitTouchCallout = "none";
like image 21
Brian Antonelli Avatar answered Nov 14 '22 08:11

Brian Antonelli


 - (void)webViewDidFinishLoad:(UIWebView *)webView
 {
    [webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"];
 }
like image 2
Hsm Avatar answered Nov 14 '22 07:11

Hsm