fill UIWebVIew TextInput with custom keyboard - iphone

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.

Related

How can I detect focus in textfields in a webview using Swift 3?

I am building an application, and when I load a website in webview using Swift 3, the screen will appear like this, now I want to detect when user clicks on the email text field, and add a button to the navigation controller.
I don't know how to do it, does anyone have any idea?
The main use of webview is near like an iframe in web.
I mean that webview is just a displaying of internet content. By this way, you cannot detect any action like user clicks on email textfield.
According to me and currently, there is no possibility to do that because it is not the goal of a webview.

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.

iPhone: A built in way to show the user a simple warning/alert message

I have a custom built sign up component that I would like to enhance. I would like to show error messages before sending the data to the server (like "invalid email") using a built in alert system (other than modal) if possible. Is there any on iOS? Do I have to build one myself? I saw that some apps show a grey rectangle near the bottom of the screen, is that custom built?
Thanks!
Check out this code sample if you want to use Tweetbot style notifications in your application, these are non modal
http://blog.mugunthkumar.com/coding/ios-code-tweetbot-like-alertpanels/
All iOS alerts are modal (for now). You will have to build your own if you want different functionality, but it isn't too difficult. You can put together a little UIView with a label that is normally hidden. Then just set the text and show it when you need to.

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

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.

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.