Need your advice:
I need to change view of all cells, when one exact cell is selected.
Par example, I tap on the 5th cell and it changes the color of 4 previous cells
One of the cells can't be selected when the other ones are selected.
Par example, the 5th cell can't be selected when one (or some) of the previous ones is selected.
So add logic to your tableView(_:didSelectRowAt:) delegate method that tells the table view to reload the affected cells. (You'll need to reload both the 4 previous cells and the 4 cells prior to the previously selected cell.)
Then update your tableView(_:cellForRowAt:) method to set the color of cells based on the currently selected cell.
Related
Recently I have been trying to create a table view with different table view cells. What I want to do is that when users click on each table view cell, it shows an extra cell underneath the selected cell to handle user inputs and the extra section disappears when the cell is unselected.
I am fairly new to iOS development and I am wondering what would be the best way to achieve this. At the moment I am thinking of hiding the extra cells initially and displaying each of them when the cell above is selected.
Any help would be appreciated.
Apple has a great set of sample code that demonstrates the behavior you're looking for — displaying a cell beneath another cell when selected. This behavior is used in Calendar when displaying a date picker, and it's pretty much what you've described.
Question: Will each cell have an identical set of options?
If so, I'd consider including the user inputs as part of the source cell and adjusting the height of the source on selection. You can animate the cell's height changing using tableView's beginUpdates and endUpdates. This way, you avoid messing around with cell indices.
I have a table view set up in a view controller. When the user selects a row, a check mark appears. When the deselect the user deselects the row the check mark disappears.
The cell is a custom cell with two labels inside of it. When a checkmark appears it shifts both labels left. How can I prevent this?
I am using autolayout/constraints and it is not an option not to use them.
Any ideas?
I have few types of cell in table view and sometimes, for some field, these types are merged in one cell. For instance, I have cells for date and for simple text input, but sometimes those cells can be merged in one like here :
If any chance I can use UITableView standard pool for reusing this cells (inside one that include them).
My concern is when I get 3 cell inside tableView:cellAtIndexPath: (compound cell, date and text cell). When compound cell will be released table view will reuse date and text cell too? How tableView knows if it's use cell or not?
I know it can be done with custom layout for UICollectionView, but I want to know is that feasible for UITableView
I'm having three buttons on table view cell and have to show some text on label below it but when i'm clicking on button and selecting text it shows in all row and if second button clicks data of first label get blank so is their any way to fill data seprately to cell of table view
Yes it is you have to test for indexPath to see if that cell will display or not what you want. And keep in mind that cell are reused so you have also to remove content from cells or use different cell identifiers for each type of cell.
I have a UITableView with many cells that it cannot display all of them at one time.
For example, the table's height is 220 (44*5), and the height of a single cell is 44.
and there is altogether 10 cells, so I have to scroll the table to display cells.
My question is, how can I find if a cell is current first and last cell of current displayed tableView,
since I want to always make some special effects for the first and last cell being displayed at any time.
Thanks a lot!
Yes,WhatEver you want,you can get with NSIndexPath.get your cell IndexPath and make effects.