In my iPhone app,I am using a web view in a view controller. When I press and hold the screen,some selections come on webview, at times a action sheet comes which has "copy" and "cancel" buttons
How to remove this ?
In my iPhone app,I am using a web view in a view controller. When I press and hold the screen,some selections come on webview, at times a action sheet comes which has "copy" and "cancel" buttons
How to remove this ?
you can disable the selection by using this code
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none'; document.body.style.KhtmlUserSelect='none'"];
if you using Jscript in your web page then this could do the trick
[webView stringByEvaluatingJavaScriptFromString:@"window.getSelection().removeAllRanges();"];
if you want to disable copy paste then this could do the trick
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:) ||
action == @selector(select:)||
action == @selector(paste:)||
action == @selector(cut:))
{
return NO;
}
return [super canPerformAction:action withSender:sender];
}
OR
webView.userInteractionEnabled=NO; // in case you need to disable whole UIWebView
If you are using .css, you can add these to the appropriate style
*.noselect {
-webkit-user-select:none;
-webkit-touch-callout:none;
}