In my app,i am using tableviews, populated through XML parsing, i get my XML from an ftp, the XML contains other xml urls for the next views and images urls and text, the problem is when an element of the tableview is selected it pushes to another view, But load for a very long time.
I run my app into the simulator, i never tested it on a device.
does anybody knows what may be the problem?
Is it a connection issue?
will it work fine on a device?
I would suggest testing your code on a device and not making assumptions about the peformace. I assume you are going to the server and ask for those images to display in the pushed view. In which case you should load the view with image placeholders and spin off the downloading images in a secondary thread (good habit for slow loading as to not block the UI) and update the image placeholders as the image data become available.
I will gladly update this answer if you need more specific help.
If you are loading a tableview in your pushed view, the hang will happen on the view before that pushed view (that is very terrible UX). So move the logic of the code that take a while into the subclass of the “pushed view”, you can implement something like a spinner (I use MBProgressHud) while you crunch you data. This way you will get the view loaded before the lag begins.
Now the flow to improve UX can be as follows:
1. In the
- (void)viewDidLoadof the pushed view you can hide the tableview (or not).2. In the
-(void)viewDidAppear:(BOOL)animatedof the pushed view throw up a spinner for the user to know you are doing work (work here being going to the server to look for the images from the urls) and do the work.3. When you know that all your data is downloaded just load the table, hide the spinner and show the table. You can do this at the end of the
-(void)viewDidAppear:(BOOL)animatedmethod.I recommend sending all the expensive work into a secondary thread, because a user would hate to decide not to wait and have a blocked back button in the navigation bar. But for to answer you original question you pushed view should load immediately, but then wait to get the data.