Table Contents not Visible Until Table Scrolls - iphone

I am new to iphone Development. I am parsing XML into a mutable array of strings which displays dynamically in a table. I am not able so see the content in the table but as soon as I scroll down the contents are displayed. Please help me out.Thanks

Can't say for certain without seeing the code but it sounds like – tableView:cellForRowAtIndexPath: returns empty cells at first. Most likely it does so because your datasource, in this case the xml parser, has not yet provided data for the cells when the table first loads.
The table only populates the visible rows and then stops. It only fetches more data when you scroll and new cells become visible. In your case, it sounds like the table has no data when it first loads but in the time it takes you to manually scroll it, it has found the data.
You probably need to call reload on the table to force it load the data. Even better, you should alter your design to make sure it has some data to display before the table itself loads. If that is not possible, you should have some placeholder information in the cells e.g. text that says "Loading Data..." and then call reload.

The problem is that when you finish parsing your XML file, you don't reload your table that is already visible.
You have to use something like [myTableView reloadData]; right after finish parsing the XML file.
Cheers,
VFN

Related

General understanding about tableview Drawing

I have a generic question about tableview Draw and reload data, and wanted some insight from this scenario. I have a tableView which get's lazily loaded getting the data parsed from a url. Now the concern is when i select a button and move to another view, I can deselect the object from there, which will remove it from the array. Thus, when I go back to the main view of the tableView, it download's the data again and check's if the object of the further view array is there or not, therefore it set it selected the button.
My concern is, when I go back, my previous selected button is highlighted, and then it does all the computation and de-selects it when the data gets loaded. Is there anyway, I can have the tableView redrawn until the data load's everytime?
Thanks.
It Looks like that when you are downloading the data & parsing the downloaded data, you are directly passing the modified variable as a source for the tableview. Instead of it, You may store the source for the tableview into another array, which will get updated from source array if it is downloaded & parsed.
Load the tableview using the secondary array.
This is my understanding. If your problem is not resolved , please provide some piece of code for the problem.
BTW, your problem can be resolved using the above solution.

iOS UI - how to tell user that there are no data in table view?

This is the situation:
A user filters a database by selecting keywords from a list, then presses "search". This pushes an instance of a UITableViewController subclass onto the navigation stack.
In the viewWillAppear: method, data are fetched from Core Data and stored in an ivar, ready for the table view's data source and delegate methods.
So far so good.
The UI problem arises when there are no results.
This simple architecture means that an empty result set yields an empty table view with no explanations.
It would be good for the UI to tell the user something like "Your search gave no results, please try with fewer keywords".
My question is this:
What is the best way to provide relevant feedback to the user, without having to change the architecture too much?
I was thinking about using the table header, but what do my esteemed colleagues here think?
Using the table header is not a bad option. You can go for that. You can also try other options like showing the info in a simple label or perhaps even an alert. But personally I wouldnt recommend the alert.
U can show that in UIAlertView.
You could add / show a UILabel to your view that says "No search results" (or something like that) when the table does not contain any data.
After fetching the result from core data... just count the number of rows in the result and then before displaying Table View just check if Count>0 then only go for table view ... else just display UIAlertView... this will save u from unnecessary display of UITableView
You can put AlertView when your ivar is empty and in alert button index return to the main view from where you are entering your search. This is the best way for you without changing your architecture.

Animating TableView Instead of Plain Reloading

I am trying to animate the reloading of a table view. Currently, I download the array of table view items and if the user reloads the table view manually, it downloads into a separate array, compares the current to the newly downloaded, and if they are different, it reloads the table view with the newly downloaded array. Is there an easy way to, somehow, compare the arrays and insert/delete rows (animated, of course) accordingly?
I found the Apple's Table View Programming Guide to be very useful for this question:
http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/TableView_iPhone/ManageInsertDeleteRow/ManageInsertDeleteRow.html
If you are using arrays, you would need to deal with figuring out inserted/deleted rows. If you are dealing with a larget set of data, then you should consider using Core Data with NSFetchedResultsController. See documentation for NSFetchedResultsControllerDelegate for getting inserted/deleted rows.

How to stop UITableView of reloading data and calling tableView:cellForRowAtIndexPath:?

I've got another problem my my UITableView: I dynamically load "Questions" from a XML File and show them inside cells of my UITableView, where the user can also answer them. The Problem is: if you scroll down, and then scroll up again, the answers that you typed before, just disappear. I've also noticed that UITableView calls the method tableView:cellForRowAtIndexPath: again, and that is exacty my problem, cause this method loads the questions from the XML File again so that all the answers that the User has typed get lost.
How can I keep all the cells in memory, and stop doing lazy loading of the cells?
I would appreciate any suggestions.
Thanks!
Store and preserve retrieved data in an NSMutableArray and hook this up as a data source to the table view.

How to implement "Load 25 More" in UITableViewController

I am working on an iphone application. Application loads plenty of records from a webservice into table view controller. I would like to load 25 records initially and remaining in 25 batch on clicking something like "Load 25 more" at the end of the table view.
Any help would be grealy appreciated.
Thanks
Just put a button connected to an Event in your table footer. When the button is clicked, append the next 25 results to your already existing array of items.
After that, just do a [self.tableView setNeedsDisplay]. I use that to let my table know I have extra data in the table. By using that, there is no need to scroll to the right line in the table, because it keeps its original position.
Also, why call the viewDidAppear method, this seems wrong to me, because (ofcourse) the view already appeared and all declerations and assignments you do there are re-done. Just put the stuff you need to be done while viewing the view AND when you are appending data in a seperate method and put call that method from your button-press event and from the viewDidAppear event.
I wrote an example project that does this which you can download from GitHub https://github.com/Abizern/PartialTable
I do almost the same in my application, getting 50 first records from webservice. As a table footer I have a view with next/previous buttons, that when pressed launch a fetching request for next/previous 50 results. After fetch request is processed I call viewWillAppear:animated: for my view controller and inside to [self.tableView reloadData], so these results show up in the same table view. Of cause I'm keeping the data each time only for presented results, but it depends on your needs.
Hope this helps
I wrote something that does exactly what you describe, an put it on github : https://github.com/nmondollot/NMPaginator
It encapsulates pagination, and works with pretty much any webservice using page and per_page parameters. It also features a UITableView with automatic fetching of next results as you scroll down.
Hope it'll be useful.