Search code examples
objective-cuitableviewuinavigationcontrollerdelay

Objective-C – Delay UINavigationController pushViewController


I use a UINavigationController together with a UITableView so that when the user touches a cell it will push another view controller on to the screen.

In this view controller that I'm pushing on to the screen I'm loading some HTML in a UIWebView so that takes some time before it has finished loading the HTML. I would like to delay the navigation controller (so it waits until the HTML has finished loading) and then pushing the view controller on to the screen. How can I achieve this programatically?


Solution

  • Would

    [performSelector:withObject:afterDelay:][1]
    

    work for you? Something along the lines of:

    [navigationController performSelector:@selector(pushNewViewFromTableCell:) withObject:view afterDelay:1.0]
    

    But you should be careful about the delayed response that this would produce: the user would touch a row, then, after a delay, the controller would be pushed.

    Possibly, you would be better off by displaying a progress indicator in the new view pushed on the navigation controller while it is loading data.