Triggering UIWebView To Sense Failed Load

Discussion in 'iOS Development' started by Exosion, Apr 1, 2009.

  1. Exosion

    Exosion Member

    Joined:
    Nov 4, 2007
    Messages:
    843
    Likes Received:
    7
    Device:
    iPhone 5 (Black)
    I'm building a web browser for app store submission, and apple will not accept it if there is no notification for a failed page load. I used IB (UIWebView specifically) to build the app, and I have no idea how I can get a delegate or a trigger to sense when a page hasn't loaded correctly, then display my error:

    I'm pretty new at this, so please give me a step by step instruction bit and realize I'm pretty noobish still.

    Please Register or Log in to view images

  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Code:
    yourwebview.delegate = _delegatehere_;
    then in that delegate object

    Code:
    - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
            // Do stuff here
    }
  3. Exosion

    Exosion Member

    Joined:
    Nov 4, 2007
    Messages:
    843
    Likes Received:
    7
    Device:
    iPhone 5 (Black)
    I'm sorry, but I'm not 100% sure what to do with each code. Like where to put it. Can you break it down a little more?
  4. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    It can not be broken down more than it already is.

    It's literally as simple as setting up some object as your webview delegate. Usually, you'd just use the view controller. Then overriding that method.
  5. Exosion

    Exosion Member

    Joined:
    Nov 4, 2007
    Messages:
    843
    Likes Received:
    7
    Device:
    iPhone 5 (Black)
    Alright got it working, thanks again.

    Please Register or Log in to view images

    This can be closed.
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Closing threads once a solution is found is a horrible thing to do. It ensures that your thread drops to the bottom of the threads list, making it more difficult for other users with the same question to find the solution. Also, someone could be reading this and want it to be expanded upon.

    The thread will remain open.

Share This Page