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.
Related
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.
I have another question open where I'm trying to figure out how to reload the collectionView without auto-scrolling. I was also realizing there are a lot of other situations where I will need to change things in the collection view. Also I have some items that I will want to change the .alpha on and change the text of. Is there a way to do all of this in Swift? For example (to be specific) if I have a collection view with a view in each cell and that view has a textField in it, can I change the alpha and text, (change alpha with animation even) without reloading entire table?
Look at the documentation for UICollectionView. There are several "reload" methods:
reloadData()
reloadSections(_:)
reloadItems(at:)
If you just want to reload a single item, update your data source's data and then call reloadItems(at:) passing in the index path for the item.
Another option, if a cell is currently visible, is to use the cellForItem(at:) method to get a reference to an existing cell. Then you can directly access UI components of the cell as needed. You should also update your data model as needed so if the user scrolls and comes back, the cell will be rendered properly.
Most appropriate where you can update your custom view of a particular UIcollectionViewcell is reloadItemsAtIndexPaths.
You would be handling a particular item than whole collectionview with reloadData.
You can handle it via notifications or some call backs in your code where you can make decision when to update which cell.
Hope it will help you.
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.
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
Maybe I'm missing something obvious, but I'm have a hard time programmatically setting the row selection in a tableView. The goal is to simply have a tableView open with a row already selected. The problem appears to be that I have to wait until the tableView is fully loaded before I can modify the selection.
I've read various strategies such as calling reloadData for the tableView in the viewController's viewWillAppear method, then immediately calling selectRowAtIndexPath for the target row. But when I do that, I get a range exception because the tableView has zero rows at that point. The UITableViewDelegate methods (numberOfRowsInSection, etc.) don't appear to be called immediately in response to reloadData (which makes sense if the table rows are drawn "lazily").
The only way I've been able to get this to work is to call selectRowAtIndexPath after a short delay, but then you can see the tableView scroll the selected row into view.
Surely, there's a better way of doing this?
Well, you can use another strategy. You can create a hidden table view, configure how you want and than show to user. Use the tableview.hidden = YES.