objective c - Reload model for UITableViewController before [tableview reloadData] -


This is my first attempt in iPhone development and I have some UITableViewController which will show data as a webservice returned from.

In my AppDelegate, I have set up a timer that is called every few seconds and reloads the model. I keep the same object reference and only refresh the content, so I have the same object on any UITableViewController which is currently visible.

When the data applet, I call:

  [[(UITABLE viui controller *) [self. Navigation controller top widget controller] tableview] reloaded data];  

Model is basically a collection of file objects. Each file object has some properties and flags.

This works very well if the current UITableViewController is a simple table with a segment, which maps to each map files . Cell in a sequential index on the array of

But I'm one of the UITableViewController s that shows it by the file and the code On the basis of the flag, we will show 2 or 3 sections. I have put this argument here:

  - (NSInteger) numberOfSectionsInTableView: (UITableView *) table view {if ([[_file status] intValue and downloader) {kIndexTransferSpeed ​​= 1 ; KIndexSettings = 2; Return 3; } And {kIndexSettings = 1; KIndexTransferSpeed ​​= -1; Return 2; }}  

on this controller, my -tableView: cellForRowAtIndexPath: just a large if statement that will show from the property _file object depends on indexPath .

The problem with this approach is that when this table is being reloaded on the device, then I can actually see it reloading section titles for a moment and flashing cells Take a little to show. Especially if I am scrolling to the table, when it is reloaded.

I have read somewhere that I should stop putting any arguments on code which is UITableViewController methods but what should I do?

I thought about a specific method that will create a "data visual model" which can be prepared with the data - tableView: cellForRowAtIndexPath: and it is created by app deget It will be called [tableView reloadData] but I would have to recreate this whole "visual model" every time, because it is the same thing and I do not really know what has changed on the data model.

reload data to handle many things in which sections come and go, Object Relative Order etc. Actually what is happening, its knowledge can sometimes do nothing without it, but originally made Teandown and the table again.

If you want to avoid that, you can notify the controller of that particular change instead. Instead of basically reloading all data through your data source in your controller instead of your view, the controller tells you how the above date and how.

This is more than just loading again, but it uses more efficient, less power, and because the UI has better information, not only completely disappearing and again Avoids appearing, but can actually be animated in changes.

The methods you want to see are:

  - UPDates (zero) start; // Allow multiple insert / delete rows and sections to be animated together Nesteable - (zero) endupdates; // Call / Delete / reload calls only within one update block, otherwise things like line count, etc. may be invalid. - (zero) insert signal:: (NISINXxSet *) Randomization with class: (UITTViewer animation animation); - Remove (Zero) Sections: (NSIndexSet *) Animation with sections: (UITableViewRowAnimation) animation; - (zero) reload section: (NSIndexSet *) with sections; Other animations: (UITableViewRowAnimation) animation; - (void) insertRowsAtIndexPaths: RAVAnimation with (NSArray *) index: (UITableViewRowAnimation) animation; - (void) deleteRowsAtIndexPaths: RAVAnimation with (NSArray *) index: (UITableViewRowAnimation) animation; - (empty) reloads RowsAtIndexPaths: RAVAnimation with (NSArray *) index: (UITableViewRowAnimation) animation;  

More documentation is available.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -