I have an iPad application that makes use of a UIWebView to display a few URLs in the application itself. I am also using SVProgressHUD control to display a few user alerts on screen depending on the state.
My issue is that I want to elegantly handle the view when an error is displayed. When the UIWebView error delegate method is called I am displaying an instance of SVProgressHUD to the user to inform them of an error using the following:
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[SVProgressHUD dismissWithError:@"An Error Has Occurred\nCheck Network Connection." afterDelay:2.0];
{
In addition to this, I wish to do something else. Either pop the view off the stack and take the user back to the previous page or fade in a UIImage which shows a custom created 404 page. I haven’t really decided yet. However, my issue is how do I detect that the instance of SVProgressHUD has disappeared from view so that I can do my next step without them overlapping?
Or create some kind of timer so that it waits a few seconds before displaying the UIImage or a Label on the display?
I would suggest to subclass (or, if you prefer, directly modify
SVProgressHUDsource) so that when thedismissmethod is executed a notification of a given type (say, SUVHUDDismissedNotification) is sent to the notification center; if your UIWebView delegate registers for such notifications, you will have the trick done.That’s really 2 lines of code…