Skip to content

Instantly share code, notes, and snippets.

@lvyile
Last active January 4, 2016 01:59
Show Gist options
  • Save lvyile/8552322 to your computer and use it in GitHub Desktop.
Save lvyile/8552322 to your computer and use it in GitHub Desktop.
UIWebView 禁止长按和选择 (Client/Server,2套方案)
#pragma mark - Client
#pragma mark UIWebViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Disable user selection
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
// Disable callout
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
}
#pragma mark - Web
//https://developer.apple.com/library/safari/samplecode/FingerTips/Listings/style_css.html
/* disable some default behaviors that would not fit nicely in a web app */
// in css file, add this line:
// -webkit-touch-callout: none;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment