"Loading" popup / progress bar
Hi :)
I am developing an iPhone App that should load a XML page from the Web and doing something with it. The problem is that the application freezes while it's downloading the page and it looks ugly. I'd like to show some kind of "Loading, please" message with a rotating wheel... What's the right approach? I tried to use aNSThread
but i receive this err开发者_StackOverflow中文版or:
Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.
This is the obj-C code that i'm using to load the XML page:
NSString* xmlUrl = [NSString stringWithFormat:@"http://urltothexmlpage"];
NSString* XML = [NSString stringWithContentsOfURL:[NSURL URLWithString:xmlUrl]
encoding:NSUTF8StringEncoding
error:nil];
I don't know the specifics of your app, but the best scenario would be to perform an asynchronous request of the xml. Letting your users to wait is never a good thing. You could use ASIHTTPRequest to process the request since it's a very easy to use framework. Check the "Creating an asynchronous request" part.
Check out MBProgressHUD for the loading screen.
精彩评论