How to drag the url in WebView and drop to a textlabel - iphone

I have a webview and want to drag the url on the webview to a textlabel.
I know there is the option of 'Copy', but I prefer to do as the dragdrop function in normal computer.
Is this possible for iphone app?
Welcome any comment
Thanks
interdev

I am assuming you want to drag&drop a hyperlink from an HTML page rendered in a UIWebView control to another control on the screen.
Unfortunately I doubt that this is trivial, if at all possible. There is no documented way to find out if a UIControlEventTouchDown event received by a UIWebView object is hitting a rendered hyperlink and discover that hyperlink's URL.
If you were able to do that, you would still have to create and show a custom view that would track touchesMoved and touchesEnded to know when the user drops it, and if it falls on the intended destination control.

Related

How to show pages index in side when showing the pdf in uiwebview

In the above image, we can see the navigationbar and pages index(side) which can viewed when the user tapped the screen once and will be removed from superview, on another tap.
I added the navigationbar using tap gesture recogniser, but to show the pages index I didn't know what to do and even how to search in google?
Any help will be appreciated.
Since you have added the uiwebviewtag to your question, I guess you are using a uiwebview to read the pdf.
In this case, there is no way to add a sidebar with the page index.
The only way do it is to develop your own viewer using Quartz, or to use an existing library.

How would I go about detecting links in TTTAttributedLabel?

I have a table view and in some of the cells there are links, I want to be allow the user to click on these links and view them in a webView (which I have already made). I don't want to use the row selection event because there may be more than one link in the cell. I came across TTTAttributedLabel and think it will be ideal. I don't need to add any style to the text in the cell, I only need to detect the links and capture the click event to open up my webview.
Any help would be greatly appreciated.
It looks like you can assign a TTTAttributedLabelDelegate to a TTTAttributedLabel that will get call backs for when a user selects different link types, but no opportunity for you to capture them and open your own web view (which I think is what you're trying to accomplish).
Instead, you might wanna check out OHAttributedLabel. It's similar in functionality, but when a user clicks on one of the links in the label, it calls -(BOOL)attributedLabel:(OHAttributedLabel*)attributedLabel shouldFollowLink:(NSTextCheckingResult*)linkInfo on it's OHAttributedLabelDelegate, which gives you the opportunity to handle the link tap yourself if you return NO.

fill UIWebVIew TextInput with custom keyboard

For an app I am working on I want a custom keyboard to come up when you tap on an input field in a UIWebview, for example for UITextView i use this code :
myText.text = [myText.text stringByAppendingString:#"a"];
but i don't know how can i fill a text field in UIWebVIew
Any help would be very much appreciated; thanks!
I don't think it's possible to use a custom keyboard for a text field within a UIWebView.
There is bidirectional communication with the UIWebView, but it is a little convoluted.
You can use stringByEvaluatingJavaScriptFromString to execute any javascript in the context of the web page. That can be used to send data to the web page, modify forms, or poll for data and events.
You can use webView:shouldStartLoadWithRequest:navigationType: to receive notifications from the web view. Define a custom scheme like myapp: and handle all such requests returning NO from shouldStart. You can use ajax style calls to trigger the notifications, although the actual ajax call will always fail because you are returning NO.
If you want to have a custom keyboard show up, you must send a notification to the host application via your custom scheme, display a UITextView over the web view, then send the results back via javascript.
At least, that is the documented way to do it.
Check dcorbatta's answer in this article Custom Keyboard in UIWebView
He suggest to use a UITextField as a "media" when you detect keyboard coming up inside a UIWebView. Thus, you can use whatever Keyboard type you want on the UITextField. After users taps something, copy the text in UITextField the media via JavaScript ActiveDocument.
I spent too much time investigating that.
Blur the text inputs using JavaScript or jQuery.
Use on screen keyboard like any UIjquery plugin
Now you have to take a look at this nice keyboard and learn how to integrate it into you web pages.
http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/
One limitation.
It works only for your pages unless you hijack the page when it is done loading and attaché your keyboard and blur all text inputs when they get highlighted or focused.

how do you pop up the Save Image/Open in New Page/Copy menu on command in mobile safari?

I need to find out how to make the menu that appears in mobile safari on the iphone/touch when you tap & hold an element appear on a single tap without having to hold. how would i do this? preferably i would use webkit & no js.
UIWebView does not does not call any methods until a link is actually activated, and it does not expose any information about its subviews. There is no way to do with current SDK, you should file a bug with Apple if you need this functionality.

iPhone Cocoa hyperlink

is there a way to display a hyperlink in an iPhone native app. Is this done with a label or another UI object?
Thanks!
Joe
Take a look at Three20 TTStyledText class
Create a custom UIButton with only text (no background image) and write an IBAction on its click - you have a hyperlink...
You can embed your text along with hyper link mark ups in a uiwebview object via a static HTML file. Another way is to show the link text on a uibutton and upon click of that button open safari to navigate to the link
I suggest the following solution: Display the htperlink text as a label and put a detailed disclusure button after it. (Detailed disclosure button is an arrowhead in a circle (>). Set the button title to the url, and make an IBAction that handle the click of the button. In this action you can create a new UIWebView, display it and load the URL into it.
There is actually built-in support for this with a UITextView. Check out the accepted answer to this stackoverflow question: How to add hyperlink in iPhone app?