I've been trying to get a standard UIcollectionView to display information pulled from Parse and it is not working at all. All I need is a simple way to implement a Collection view to show the name of the item with an image to display the item. The number of items in each section is equal to the PF query. count that was performed. But I need to figure out how to display the items and how to create a working collection view.
You can refer this tutorial for UICollectionView.
It has nothing to do with the Parse or PFQuery at the moment.
Related
I need to have a search bar for a table view that displays a list of data, not sure whether I should use one table view for both displaying and searching, or have separate table views for display and search respectively.
Single table view:
+ feels easier to implement by just switching data source
- extra work if I want to maintain the scroll position (after searching) of the display table view
Separate table views:
+ no extra work needed to preserve scroll offset of the display table view
- extra work to switch between display and search modes
Is there anything critial I missed? What is the recommended way?
Update:
I need the search bar to stick on top, so it can't be the tableHeaderView of the table view (which scrolls when table view scrolls), or section header view because I've got different sections.
Thanks!
I've used a single table view and used a read only property to filter the array of items based on the search text.
I stored the original data in Property X and based on the text entered in the search bar i filtered the data returning by the Property (readonly) Y and used as the table data source.
Using the search bar delegate method you can then filter the contents of the table as the user enters text into the search bar.
The first one is the recommended way to implement the searching functionality. Managing the datasource is easier then to handle the two different tableviews.
You can try for UISearchController which provides the searchBar with a TableView and can have delegate methods to handle the case.
Here and here are some good tutorials to do the same.
Currently, what I am showing search result same tableview.
Now, I want to show results in another table view.
Here is one example of search & suggestion.
Please drag another tableview in view and when you are going to search then display that data in upper table and hide and show the upper table on the basis of search. Also create an outlet of upper tableview and apply condition in TableViewDelegate and DataSource.
I found this example which is what exactly I want. I am trying to make a table which the cells/sections collapse and expand. All the data in the parent cell and child cell are not fixed data which means I want to get them from web service (Parse). I was wondering how can I create one and what is the easiest solution to get me working with this.
I want to loop through a TableView and extract the text from all the selected rows. I suppose I "could" create and maintain a special array that is updated every time a row is selected/deselected using the didSelect/didDeselectRowAtIndexPath methods. But creating a separate array seems like an extra step. Is there no way to let the TableView itself serve as the array and then simply loop through it and get the selected rows? What would the code look like? I'm new to Swift, so this might be a silly question.
Part of the problem is that cells are supposed to be reused, and when used this way it is not possible to loop through them all. You could get around this by using a unique reuse identifier for each cell, such as the indexPath itself or some underlying unique id in your model. Then, you could indeed loop through all cells and retrieve whatever state you desired from each.
You would, however, find your application crushed under the weight of too many cells being instantiated and kept in memory. If you don't have many cells you won't be killed, but try it with a big data set and your app will enjoy a very quick death.
It is far more efficient to store one array with a bunch of id's than a large number of memory-intensive UITableViewCells.
As mentioned in comments, you should work with underlying datasource, not the table itself.
For example if your table shows rows from Array, it is way more faster to retrieve strings directly from that array than creating UITableViewCells and get strings from them.
Get indices of selected rows using UITableView's property indexPathsForSelectedRows.
Query datasource for each row.
As has been said the tableview only handles displaying, your datasource is what powers the data shown if you think about it.
Plus as said before the tableview dequeues cells as they scroll on and off the screen.
The best way to achieve what you want is to add a property to your datasource for each element that will allow you to filter out the select properties easily.
How are you storing the state for each selected cell currently? As this is the same functionally you would use to be able to generate your selected text array.
I've been working successfully with any tableviews. Now I want to display an overview from 1st fetchrequest in the first section of a grouped tableview. In the 2nd section should be shown a list of detailed informations.
Is it possible to display data in one and more data in a another tableview section?
I try to do this with static labels, for better understanding.
Should look like this screenshot - but I am a new user cant post images :(