Infinity Scroll and UITableView Data Reload - ios

I'm implementing infinity scroll to load new data in my uitableview that is implemented like Contacts style in Apple embedded App.
My datasource is a IList and then i add new elements on it.
When load new datas to that list if i don't call
this.TableView.ReloadData()
my UITableView doesn't show the new elements added.
That method generates a ugly effect of white screen for a bit, to show next, succesfully, the data added. There are others ways to do that without that effect?
For example using ReloadRows...i can't use that method because i don't understand in which way pass an NSIndexPath[] for rows that aren't loaded yet

You can use the insertrowsatindexpath methods - see the apple documentation at http://developer.apple.com/library/ios/ipad/#documentation/userexperience/conceptual/tableview_iphone/ManageInsertDeleteRow/ManageInsertDeleteRow.html - especially the batch operation section

Related

UITableView showing extra separator lines, on top of cells, when reloading page

I have a UITableView that contains mutiple sections. When my tab page first loads, everything looks fine. But when I navigate to a different tab, and come back, my UITableView has some extra separator lines.
I verified that numberOfRowsInSection is properly returning 2.
My row height is set to AutomaticDimension.
I am calling reloadData in viewDidAppear.
I tried setting the background color of my table cells to white, but the extra lines are still visible.
The UITableView is inside of a UIScrollView, which I know is frowned upon, but I am doing the calculation to calculate the size of the TableView. Everything works perfectly on initial load, it's not until I return to the tab that I get the extra lines.
In my AccountViewController, I was calling an API to get the user's get account information in ViewDidAppear.
Instead of creating a new TableViewSource, I would clear out the existing data, and the repopulate it with the result of the API call. The flow was something like this.
Clear the Source Data
Call the API
Populate Source with API data
Reload Table Data
I ended up solving the problem by making a call to Reload Table Data after the source was cleared.
Clear the Source Data
Reload Table Data
Call the API
Populate Source with API data
Reload Table Data
Perhaps not the most efficient approach, but it was the easiest to implement within the current structure of the page.

How combine UITableView reorder rows with UIDropDelegate

Using iOS 11 I'd like a UITableview to support both existing row re-ordering using the standard row drag handle and also accept dropping images via the new UITableViewDropDelegate protocol. Using the standard examples I can accept images using the tableview.dropDelegate working OK,
https://developer.apple.com/documentation/uikit/views_and_controls/table_views/supporting_drag_and_drop_in_table_views?language=objc
but as soon as I assign the dropDelegate, the existing row-reordering no longer works. I tried setting the tableview's dragDelegate and returning an array with single UIDragItem (same doc examples), but this still does not give the existing row re-ordering and the complete cell view can be dragged to "anywhere" in the app, not just in the tableview. Also the animations that show the re-order insertion position do not work.
Any idea if this (combining drag/drop + reorder) is at all possible, or should row re-ordering be handled by the dragDelegate/dropDelegate too? Plus: any example on how to do that?

Preload tableView cells and prevent reloading

I already found entries with that topic on this page and also a website that provides a tutorial for that problem. But nothing worked very well.
The tutorial sad I should double the height of my tableView so cells loaded earlier, but with a higher tableView I never reached the last cells.
My problem is, I use a tableView to display my apps mainpage. This mainPage shows every time a topic and if its necessary for that topic it shows for example a cell with a map, one with pictures and sometimes not. Problem now, if I trying to scroll to my view its always lagging because it loads a map or this pictures. And scrolling back again because the loaded cells already deleted. I used a tableView because of the possibility to switch celltypes(mapCell, pictureCell, textCell) on and off.
I understand this feature, because of memory issues but in my case its not that much and it would be better if all my cells be preloaded and stay in memory until I change the topic.
Is there a swifty way to told my tableView to have this behavior?
Thanks a lot and nice greetings
I would suggest a different approach. Set up your table view controller to install placeholder images in your cells, trigger an async download that you cache to disk, and then update the cell with it's downloaded content if it's still visible when the download is finished.
There are various third party frameworks that do all this housekeeping for you.
Declare a cell array.
Follow these steps whenever change in your topic.
Clear you array
Create and configure all cells add to your array.
Return these cells to datasource methods using row index. Don't use tableview dequeue method here.

TableView rows not updating after core data insert

I'm very new to swift programming. I have been playing around with this for a while, but I am not getting anywhere so asking here.
I have a tableview which I can load the data into the view from CoreData no problem. I have an ADD button at the top that segue's to a new tableview, with a long list of options they can pick from. This tableview also works fine, and includes a search bar.
When the user selects an item row from the second tableview, it inserts that item into CoreData and segue's back to the first tableview. This is where my problem is, the data does NOT update on the visible view.
I call tableview.reloaddata() and I can see my code calling the fetchedResultsController with the new query that would return with the new data. But the code never gets to the cellForRowAtIndexPath func so therefore the visible data view never changes. It remains the same display that was visible when the add button was pressed.
How does the visible data get updated? What am I missing?
When using an NSFetchedResultsController, if you want it to "automatically" update the contents of the tableview then there are a couple of things you need to make sure of...
You have to become the NSFetchedResultsControllerDelegate and implements the methods necessary for the updating of the table view. These are quite lengthy and can be found on the Ray Wenderlich website. The code on here is in Objective-C but it's fairly easy to convert to Swift.
The second thing you need is to make sure that the core data update is done on a background thread. Again the website linked above shows this.
Once you've done that then you don't actually need to run [tableview reloadData] because the fetched results controller methods will manage everything for you.

Filter a tableview in Titanium?

I've been trying to implement client-side filtering of a tableview in Titanium without success.
I've got three buttons that are displayed in the Navigation bar that when clicked need to filter the table view rows.
The problem is not deciding which row to show/hide it's the actual code to hide/show a row.
Titanium API docs for TableViewRow list show() and hide() methods but they don't see to work.
I can use the tableview's deleteRow method to delete the row but that means it also gets removed from the datasource which makes it impossible to show again without reloading the tableview data from the remote datasource.
i would filter on the data you have in your tableview and assign the filtered data to the tableview each time you want to filter like that:
myData = applyMyCustomFilterOnData(myData);
tableview.setData(myData);
I know it sounds silly and should be identical behavior, but have you tried the visible property instead of show() and hide()?
There are quite a few quirks in Ti, and this may be one of those small inconsistencies. We had this issue on some object or other a while back, it may have even been the TableViewRow.

Resources