Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-07-2011, 03:44 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default disable copying in UIWebView

Hey all,

I am trying to disable the function in the UIWebView that allows the user to doulbe tap the screen swipe down, creating a blue window that says copy. I am using
Code:
body
{
     width: 300px;
     height: 130px;
     font-family: verdana;
     font-size: small;
     -webkit-touch-callout: none;
     -webkit-user-select: none;
     -webkit-user-drag: none;
     -webkit-user-modify: none;
     -webkit-highlight: none;
}
in my css class but it is still happening. Is there anything else I need to put in there

Thanks
Clinton
Shades of Chaos is offline   Reply With Quote
Old 07-08-2011, 04:50 PM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

mmm...post the entire code.
__________________
dany_dev is offline   Reply With Quote
Old 07-08-2011, 05:52 PM   #3 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

This is all the css code right so far
Code:
body
{
	width: 300px;
	height: 130px;
	font-family: verdana;
	font-size: small;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-webkit-user-drag: none;
	-webkit-user-modify: none;
	-webkit-highlight: none;
}

#divContent
{
	position:absolute;
	left:15px;
	top:100px;
	width:500;
	height:500;
	border:thin;
	border-color:#000000;
	background-color:#FFFFCC;
}

#btnTest
{
	position:absolute;
	left:330px;
	top:55px;
}
Shades of Chaos is offline   Reply With Quote
Old 07-08-2011, 11:32 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 19
Vixy is on a distinguished road
Default

it has to be in html file

<style type="text/css">
body {-webkit-user-select:none}

</style>

it works for sure!!!


try disabling other options (put //) and only leaving this one
__________________

Last edited by Vixy; 07-08-2011 at 11:37 PM.
Vixy is offline   Reply With Quote
Old 07-09-2011, 02:23 AM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

when i say "post the entire code" i mean also (and mainly) the objective-c part
__________________
dany_dev is offline   Reply With Quote
Old 07-11-2011, 02:33 PM   #6 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

Hey Vixy the code you provided didn't work. I was still able to double tap the screen and drag down to make a blue copy window appear.

Dany I can't post my entire code but this is all I do with the web view
Code:
[webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:[NSURL URLWithString:@"/var/mobile/Applications/F0BB0B99-F1B1-4618-A86C-12652EBA0DB6/myApp.app/filesFolder/"]];
Thanks for the help
Shades of Chaos is offline   Reply With Quote
Old 07-11-2011, 03:53 PM   #7 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

maybe this article will help ios - Disabling user selection in UIWebView - Stack Overflow
smithdale87 is offline   Reply With Quote
Old 07-11-2011, 05:19 PM   #8 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

I already have the first method in place and I tried the other 2. I put the second method in viewDidLoad and webViewDidFinishLoad and it did nothing. I put the third method into my viewcontroller and I got an error. The _copyCutAndPasteEnabled is not declared. So I just declared it as a BOOL but I do not know what to do with that BOOL
Shades of Chaos is offline   Reply With Quote
Old 07-12-2011, 12:06 PM   #9 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 19
Vixy is on a distinguished road
Default

this describes what you want

iLessons iLearned: How to Disable UIWebView Selection

if it doesn't work you are probably changing it somewhere else in html, try finding if there are any other occurances

good luck
it worked for me!
__________________
Vixy is offline   Reply With Quote
Old 07-12-2011, 12:40 PM   #10 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 104
Shades of Chaos is on a distinguished road
Default

I have no other styles except for this in my html
Code:
<style type="text/css">
body {-webkit-user-select:none;
	-webkit-touch-callout: none;
	-webkit-user-drag: none;
	-webkit-user-modify: none;
	-webkit-highlight: none;}

</style>
And my css looks like
Code:
body
{
	width: 300px;
	height: 130px;
	font-family: verdana;
	font-size: small;
	-webkit-touch-callout: none;
	-webkit-user-select: none;
	-webkit-user-drag: none;
	-webkit-user-modify: none;
	-webkit-highlight: none;
}

#divContent
{
	position:absolute;
	left:15px;
	top:100px;
	width:500;
	height:500;
	border:thin;
	border-color:#000000;
	background-color:#FFFFCC;
}

#btnTest
{
	position:absolute;
	left:330px;
	top:55px;
}
All the copy/paste and magnifying glass have been removed with these styles but I am still able to double tap the screen and swipe down making a blue copy box at the top of my screen.
Shades of Chaos is offline   Reply With Quote
Old 08-05-2011, 05:06 AM   #11 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 79
xqtr is on a distinguished road
Default

Does anyone know how to disable copying in UIWebView for 4.3? I've tried every link above, but it doesn't work!

This is my code:

Code:
- (void)viewDidAppear:(BOOL)animated {
	[super viewDidAppear:animated];

	// String attributes - show them in the user interface
	NSString * jsCallBack = @"window.getSelection().removeAllRanges();";    
	[tvtext stringByEvaluatingJavaScriptFromString:jsCallBack];
	
	NSString *myHtml = [NSString stringWithFormat:
						@"<html><head>"
						"<style type=\"text/css\">"
						// Disable Open/Copy/Cancel alert with long link selection
						"* {"
						"-webkit-touch-callout: none;"
						// Disable selection/Copy of UIWebView
						"-webkit-user-select: none;"
						"font-family:Helvetica;"
						//"p {font-size:x-small;}"
						"body {-webkit-user-select:none;}"
						
						"}"
						",</style>"
						"</head><body>%@</body></html>", [referringObject valueForKey:@"stext"]];
	[tvtext loadHTMLString:myHtml baseURL:nil];

}
xqtr is offline   Reply With Quote
Old 10-17-2011, 05:00 AM   #12 (permalink)
Registered Member
 
Join Date: Oct 2011
Posts: 1
King.Hu is on a distinguished road
Default

Well, I'm new here, and I also found the answer.Here is the html you load into the UIWebView:
HTML Code:
<head>
<style type="text/css">
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-webkit-user-drag: none;
-webkit-user-modify: none;
-webkit-highlight: none;
}
</style>
<div
ontouchstart="touchStart(event);"
></div>
</head>
<body>TextHere with Link<a href=http://developer.apple.com>apple developer</a>
</body>
and then write the code in your view:
Code:
NSString *html=[NSString stringWithString:@"\
<html>\
<head>\
<style type=\"text/css\">\
body {\
-webkit-touch-callout: none;\
-webkit-user-select: none;\
-webkit-user-drag: none;\
-webkit-user-modify: none;\
-webkit-highlight: none;\
}\
</style>\
<div\
ontouchstart=\"touchStart(event);\"\
></div>\
</head>\
<body>%@</body>\
</html>\
"];

[webView loadHTMLString:html baseURL:nil];
for more, you can click:
Loading…
King.Hu is offline   Reply With Quote
Reply

Bookmarks

Tags
copy, disable, uiwebview, user, webkit

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 354
9 members and 345 guests
apatsufas, chemistry, lendo, leostc, Leslie80, lzwasyc, MarkC, SamorodovAlex, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:34 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0