I have a UITableViewController embedded in a navigation controller. My rightBarButtonItem is a refresh button. When pressed, the button triggers an update from a server. The update is synchronous (when I have time, I'll change it to an asynchronous request). What I want to do sounds simple in theory. Once the button is pressed:
What's happening, however, is that I will set the rightBarButton to a view with an activity indicator view, but it's not getting updated until after the table view reloads, which is obviously pointless. My server update routine looks like this:
Since it's synchronous, I thought it would simply progress one step at a time, but that's not working. How can I make it so that the activityIndicatorView shows and disappears when it's supposed to?
When you modify the navigation bar, the modifications aren't actually applied to the screen immediately, they are applied during the next screen update cycle, or next screen refresh, or next redraw.
In your code, it seems like you send a synchronous request to the server immediately after setting up your navigation bar. That request now blocks the main thread, and the system cannot refresh the screen, as all UI code runs on the main thread.
Using an asynchronous request, or simply sending the request on another thread, or some other witchcraft you'd like to try with a synchronous request will help you solve your problem. But the essence of these solutions would be the main thread will not be blocked by any synchronous methods.