Application freezes for some time
In my app I have a login view. When I enter login details and click login button, the app freezes for some time and then continues. I know it's freezing because it is communicating with remote server but how can I 开发者_高级运维prevent the freeze thing and show a nice looking status animation instead?
As you are communication with server it will takes some time, so meanwhile you can add some animation on alertview.
But by calling simply alertview it will not work.
So you have to proceed in the following steps:
1) On Submit Button Click first add Custom Indication View
2) Start Animation View
3) Call NSThread for server communication like
[NSThread detachNewThreadSelector:@selector(yourActionName) toTarget:self withObject:nil];
4) Remove Animation View
For more information go through this article: http://iphonedevcentral.blogspot.com/2010/08/safe-threaded-design-and-inter-thread.html
Your API call is blocking the GUI thread. You can circumvent this by moving the remote API request call in a NSOperation
call, and pop up a loading screen until the API call returns.
精彩评论