I have an IBAction, triggered by a UIButton.
In this IBAction I connect my app to server, returning a Plist.
During this time (between my apps connect to server, and the server returns that Plist) I want to show a UIActivityIndicator.
The problem is, when my IBAction is triggered, the apps connect first to server, an then shows the UIActivityIndicator.
My IBAction in pseudocode
- (IBAction) loginMe: (id) sender
{
// show activity indicator
// connect to server, and catch data
}
Your “connect to server” action is likely synchronous. The action “show activity monitor” is incorrectly labeled. What you’re really doing is “mark activity monitor for display next time drawing occurs.”
What you need to do is to make sure that
loginMe:returns so that the UI can update. The server connection logic needs to continue asynchronously. Generally this is done withNSURLConnection. You can find explanation in the URL Loading System Programming Guide.