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

Mockup & CodeGen, iPhone & iPad
($9.99)

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

Manu
($0.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 03-02-2010, 01:44 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default UIWebview selection (or a Rich Text View)

Since there is (as far as I know) no 'Rich Text View' available (multiple colors, and styles in the same view), I thought of using the UIWebView for this purpose, which should work fine.

Only there is one problem, I can't seem to retrieve the current selection of the user. With the UITextView this is possible, only that view does not support rich text editing.

So, is it possible to retrieve the selection? I've tried playing with Javascript for this purpose (since this is a UIWebView, and I am a web-developer from origins) but the events for retrieving selection don't seem to work on the iPhone browser (though it does work on the Apple Safari browser on the Mac), so that is something that won't work either.

Is this possible any way?

My idea is that people can 'mark' the text, like a marker on paper. (And some functionality, by being able to click the marked text and place a note there).
Matthijn is offline   Reply With Quote
Old 03-02-2010, 04:03 PM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 31
Default

You might want to look into one of two things. The first is the webView method stringByEvaluatingJavaScriptFromString:

This allows you to pull JavaScript values out of the web view and into the rest of your app

The other is maybe look at the pasteboard api, see if there is anything there that can help
__________________
lepetitapps is offline   Reply With Quote
Old 06-10-2010, 12:03 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 1
Default Found a way?

After hopelessly looking for a solution to allowing the user to select text and getting the selection from a UIWebView (without having the built-in popover appear), I was wondering if you were able to resolve this? I have tried many of the techniques suggested (subclass, transparent view, subclass of UIWindow, etc.), but even if I can obtain touch events, I have yet to actually resolve turning that touch point into drawing and obtaining the underlying html selection.

It would be wonderful if the next SDK would allow a delegate for the popover when text is selected so a custom menu for the selection can be provided and javascript injected to do something useful. Ideally, I would want to:

1) receive notification from the UIWebView that text was selected and what that text was.

2) allow me to display my own popover above that selected text

3) handle the popover selection and inject javascript back into the IUWebView to do stuff like highlight text etc.

Quote:
Originally Posted by lepetitapps View Post
You might want to look into one of two things. The first is the webView method stringByEvaluatingJavaScriptFromString:

This allows you to pull JavaScript values out of the web view and into the rest of your app

The other is maybe look at the pasteboard api, see if there is anything there that can help
0063292 is offline   Reply With Quote
Old 06-10-2010, 12:04 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 10
Default

Nope, sorry I have not resolved this issue.
Matthijn is offline   Reply With Quote
Old 06-28-2010, 03:56 AM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 3
Default

Quote:
Originally Posted by Matthijn View Post
Nope, sorry I have not resolved this issue.
I want to achieve the same thing you are looking for. If you would be abel to do please share it. I'm aslo hanging around to find the solution.

I've tried these two tutorials but couldn't things get to work:

Detecting taps and events on UIWebView – The right way The Spoken Word

Highlighting Text in a UIWebView Brainwash Inc. – iPhone/Mobile Development
loosy is offline   Reply With Quote
Reply

Bookmarks

Tags
mark, selection, uiwebview

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: 259
19 members and 240 guests
ADY, Alsahir, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, Herbie, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, Robiwan, smethorst, spiderguy84, twerner
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

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