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 th开发者_运维技巧at event and call my dismiss method?
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.
精彩评论