How do I navigate my app from inside a UIWebView?

Discussion in 'iOS Programming' started by hackrabbit, Jul 14, 2011.

  1. hackrabbit macrumors newbie

    Jul 14, 2011
    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!
  2. jiminaus macrumors 65816


    Dec 16, 2010
    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.
  3. jnoxx macrumors 65816


    Dec 29, 2010
    Aartselaar // Antwerp // Belgium
    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.)

Share This Page