UITableView data source change does not trigger UI update on iOS 13 - ios

This only happens on iOS 13.. iOS 12.x works fine.
I have a table view with a search controller, and two datasources, one for the regular functionality and one for the search functionality. (the search functionality is unrelated to the content displayed on the main table content).
After cancelling a search, the searchBarCancelButtonClicked: method is triggered, I switch from the search data source to the main datasource and reload the table view but even though the table view details show that the correct datasource is set, the UI still shows the search data source.
I tried triggering the layout refresh, but no luck.
Worth mentioning that the UITableViewDataSource methods are called on the correct data source, it's just the UI that's out of sync so to speak.
Any idea what could cause such a thing?

If I manually set the search controller inactive, it works: [self.searchController setActive:NO];

Related

cellForRowAtIndex not being called in UITableViewController?

I've currently got a single working UISearchController implemented inside the header view of a UITableViewController. I wish for my other views to also follow suit but some are UICollectionViewControllers. Is there a way to create one UISearchController and just call them across all the views within the headers? All of the results must show in a table.
I had attempted to create one for each view but the UICollectionViewController was giving me some problems. I couldn't figure out how to set and update a table for the search controller. It wouldn't allow me to override the tableView methods as i guess the controller is a CollectionView.
Any help is appreciated.
EDIT:
Should also add that the search method/data will be the same across all of the views. See how the stock iOS Music app uses search bars as an example.
EDIT 2:
I've nearly cracked it (I think). I've setup a singleton "SharingManager", within this i have 3 arrays. Now I have 2 views, one named ArtistsView and one SearchTableViewController. The Search view contains all of the table methods and the ArtistsView communicates with that using:
self.searchResultsController = UISearchController(searchResultsController: SearchTableViewController())
I also copy the variables within the singleton to variables that are within the SearchTableViewController.
The issue i'm having now is that the cellForRowAtIndexItem method is not being called. All the other ones are, i can even see the section headings are being displayed. I have set up various println() statements to see where i could've gone wrong, the numberOfRowsInSection is also returning the correct numbers. Any ideas?
What I have done in the past to solve this kind of issue, and what seems to be the most flexible is to have it so that when you tap on the searchbar, your app actually transitions to another view controller that handles the search and search results.
Fake search bar button on each screen you wish to use it.
When tapping the search bar, screen cap your current view controller.
Set the screen cap to the background of your search results controller, blurred or darkened a bit if you like, so it doesn't interfere with the search results.
Transition between your previous view controller and the new search results controller with a fade.
You'll be able to give the user the impression that they never left the original screen they were on.

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.

Performing Auto-Complete on UITextField in Swift for iOS

I'm totally new to App design for iOS. I am designing an iOS app with Swift. I have a RESTFul service that returns a list of Cities based on a partial string query. My webapp uses Jquery-AutoComplete to perform the operation and it works great, I was wondering how I can achieve the same drop-down list look with Swift.
Here's how I retrieve the data. If the size of UITextField is greater than 3 characters, my App Starts sending the content of the UITextField to my RESTFul Service and get back the list of cities that start with those characters (My service returns the top 10 matches).
My challenge is, how can I show a drop-down under the UITextField just like JQuery-AutoComplete list ?
From comments above:
I would use a UITableView underneath your UITextField, which you would then populate its data source with the response from your web service.
does it integrate seamlessly ? I mean when there is no data it hides automatically or I have to track its visibility ?
You can set the hidden property of the table view depending on whether there is anything to display from the web service response. If there is no data set hidden to TRUE, if there is data set it to FALSE and use the reloadData method to reload the table views data source.
Thanks. So one last question, If I have stuff under the UITextField, when I set the visibility of UITableView, is it going to appear over the background and elements under the UITextField or it's going to push them down and rearrange the UI ?
This all depends on how you set up your UI. I would add the table view as a subview of the main view which would add it above any other objects. Again, however, this would depend on how the rest of the UI is set up. You can use the insertSubview: aboveSubview: method to make sure the table view is above all other views. Setting the hidden property of the table view to TRUE will not have any affect with regards background of objects underneath.

Web services data is coming late and table view is empty

I am new to ios sdk, working on app which includes web service calling and parsing JSOn.i have two view controllers on first view i am calling web service on button click and in second view i have to display all record in table view. everything working well , parsing values are also coming properly. but values are coming late and table is displaying empty values. but when i am navigating back and coming again then it will display all button.How to handle this situation?
The beauty of Asynchronous download is making things ready for us in other than main thread. All UI components gets updated by Application main thread, In your case TableView UI updating on main thread and downloading happening in separately. I guess only thing you might missed here is, after downloading finished not getting the notification. Once you arrange notification after downloading process finished, just update your tableView by calling [tableviewobject reload];. Which ll done all reloading of the tableview(this is nothing but refreshing all tableview again). Good luck.
Are you reloading the table view once the data has been downloaded?
Something like this in your Table view controller:
[self.tableView reload];

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