开发者

Make the user able to autopaste info in forms in UIWebView

After a few hours of googlening and testing I gave up the whole autofill a form in uiwebview and will now try another approch. However, I have no idea how to make it work.

All I really wanna do is to have two buttons, "username" and "password". The user will then highlight one of the forms textfields inside the webview and then press on of the buttons and the username will be printed in the textfield (if they pushed the username button that is).

So i want help with trying to understand how to control when they are highlighting a textfiled (ofc the keyboard will show up) and how i simulate a pastefunction.

开发者_如何学JAVAThank you


You can modify the content of an UIWebView injecting JavaScript, there are a few topics around here about that (edit: Also check this page).

In fact, you could automatically hand the the login/password directly through a javascript submit form action, instead of having to fill the visual form.

To get the contents of the Clipboard, use:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSString *pastedText = pasteboard.string;

(Note: The pasteboard is independent from your OS, meaning that if you copy something, it won't be recognized in the iphone app, you need to copy something from inside your iphone/simulator, the easiest way is to add a temporary UITextField, or go to the home screen, and get to the search page, and write there)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜