Reputation: 1207
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 ?
Upvotes: 1
Views: 2438
Reputation: 949
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.
Upvotes: 2