我怎样才能知道什么时候用 UIWebview 的键盘敲击了 go 呢?
我有一个简单的模态视图,其中包含一个 Web 视图,当用户需要在基于 Web 的 iPhone 应用程序中进行身份验证时,该视图会弹出。用户使用实际的网站登录进行身份验证,然后他们应该点击“完成”,视图就会消失。
一旦用户点击网络视图键盘上的 go,我就需要能够触发解雇命令。我知道如何使用 UITextfieldDelegate 和 textFieldShouldReturn 方法完成它,但我无法使用 webview 的键盘让它工作。
如何捕获该事件并调用解雇方法?
I have a simple modalview that contains a webview that pops up when a user needs to authenticate in a web based iPhone app. The user authenticates using the actual website login, and then they should hit done, and the view dismisses.
I need to be able to fire the dismiss command once the user hits go on the webview's keyboard. I know how it is done using the UITextfieldDelegate and the textFieldShouldReturn method, but I can't get it to work using the webview's keyboard.
How can I capture that event and call my dismiss method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 UIWebViewDelegate 从 UIWebView 接收事件。您应该使用的方法称为
webView:shouldStartLoadWithRequest:navigationType:
只需在类中实现此方法并将该类设置为 Web 视图的委托即可。然后,每次 Web 视图即将加载新页面时,您都会收到一个请求。根据请求的属性,您可以决定用户是否已登录。
顺便问一下,您想在用户点击 go 后关闭哪个视图?我认为键盘已经被解雇了。
You can use UIWebViewDelegate for receiving events from UIWebView. The method you should use is called
webView:shouldStartLoadWithRequest:navigationType:
Just implement this method within your class and set the class as web view's delegate. Then you will receive a request each time the web view is about to load a new page. Based on the properties of the request you can decide whether user has logged in or not.
By the way, which view do you want to dismiss after the user hits go? I think the keyboard is already dismissed.