PDA

View Full Version : How do I navigate my app from inside a UIWebView?




hackrabbit
Jul 14, 2011, 01:55 PM
Here is my problem that I've been trying to figure out for a week now, so any help would be unbelievably appreciated:

I have made a login screen in html that is hosted on my server that authenticates users and redirects them to their profile page. I am opening up that webpage (just a username/ password field and a login button) in a UIWebView in my iPhone app. I want to have the login button redirect to the menu in my app instead of redirecting to another webpage. How can I do this? Cheers!



jiminaus
Jul 14, 2011, 03:47 PM
I have one idea (untested, but theoretically sound). Set up a delegate for your UIWebView and handle webView:shouldStartLoadWithRequest:navigationType:. In that, if the request is for the profile page, transition to your menu instead.

The usual way to do this is to present a login UI instead of load a login webpage. From the login UI, you programmatically make a login HTTP request to your reserve, and then process the response. This recent thread discusses how to send a POST HTTP request.

jnoxx
Jul 15, 2011, 02:59 AM
Or you create webservices, which post back XML/JSON, so you can parse it in a login page. which will save you more headeaches I think.
Save the user as a Singleton user, so u can acces it anywhere (it's info etc.)