What is the best way to show and hide rows related to a section on tap?
I have a table view with multiple sections and populated with data
I want to hide the rows when the user press on the section
What is the best practice to achieve that?
Here is maybe the answer to your question. (you can expand and collapse the height of a cell)
Swift: How to animate the rowHeight of a UITableView?
Related
I am working on a app which includes table cells. I want that when i swipe table cell it shows two options, first about that cell value and another for delete that value. How can i show that in a way that the cell value shows in half of cell and the options show in half of cell.
Thanks in advance.
There are an out of the box solution, called HHPanningTableViewCell. It does exactly what you need!
HHPanningTableViewCell is a UITableViewCell implementing "swipe to reveal" a drawer view. Such a view typically holds action buttons applying to the current row.
This library, SWTableViewCell, should help you:
https://github.com/CEWendel/SWTableViewCell
An easy-to-use UITableViewCell subclass that implements a swipeable content view which exposes utility buttons (similar to iOS 7 Mail Application)
You have to create a custom cell and override Apple's behavior which is swipe left to delete and then show your options. You can add gesture recognizer to the cell and on swipe to left animate the cell content view and animate in your option view or however you like it to be. I can write up an example code if you need.
I have a client that would like this implemented:
http://i.imgur.com/hWxfg.png
X expandable views each with a scrollable tableview with Y cells.
The main view is not scrollable. If i tap Drawer C then Drawer A should collapse and Drawer C should expand.
I've seen similar constructs, but not with tableviews inside, so I don't know exactly how to go around this.
What's the best approach to this?
1) A tableview with "inner" tableviews
2) Multiple customs views with a button and a tableview
3) Something other?
How would you implement this?
Thx!
I have done this type of implementation but dont carry source code with me.. still i can guide u the way i did it...
i will explain u the way i did and considering ur example image.
u will need 3 buttons (give them diff tags) with 3 bool flags to handle their on off state.
u will need 3 tableview(give them diff tags)
if screen height is 480 and all button height is 20, then remaining height will be 480-3*20=420.
so this is the height of all the table view.
on the click event of any button ,based on clicked button tag find its associated table view .
set the flag value on button click and using the bool flags value decide to show and hide the table view and also the on/off image on the button.
I have a tableview with custom cells. Each cell has a UITextfield. When the last cell's textfield is clicked, the keyboard pops up and covers it and the table view won't scroll up any further. Is there a property of UITableview that can be set so that the last cell can scroll to half way up the screen?
Thanks in advance
There are a two ways to approach this (that I can think about off the top of my head):
You can use the tableFooterView property of UITableView to set an arbitrary, empty view to be about half the size of your table.
You can add empty cells to the bottom of your table
Both of these approaches will accomplish roughly the same thing, but using the tableFooterView property is probably your best bet.
see Making a UITableView scroll when text field is selected for a list of solution..
Also basing your view controller from UITableViewController (since you say its a table) will provide all this functionality automatically!
Let's say we have a UITableView with some 100 rows, we select a row and after that we scroll the UITableView. The selected row is also scrolled top or bottom direction but I want the selected row to be always visible to the user while scrolling the table. Is it possible ?? please help me out which sample code..(it is same like twitter scrolling)
If you want this, you'll have to write a completely custom tableview from scratch (which I believe was done for Twitter.app). There's no way to do that with the built-in tableview.
Is there anything currently in the SDK that allows for re-ordering of tableView sections? As in, move the entire section below or above an adjacent section? This is plausible with individual UITableViewCells. Haven't seen it done for sections though.
Maybe not ideal but fairly simple so worth considering:
Add Up/Down buttons to your section headers. Down on the first, Up on the last and Up and Down on all the others. Then respond to the button presses by programmatically re-ordering the table. Up moves the section up one and Down moves the section down one.
Martin
There's no built-in touch-responsive API for moving table view sections - you'd have to do it programmatically then send a [tableView reloadData] message or similar.
It is concievable, though, that you create a table view where each UITableViewCell's view is itself a UITableView containing a section of your data, so that the cells in the "master" table are draggable as UITableViewCells. This would let you reorder "sections" in your table, but they wouldn't be sections anymore - they'd be separate tables, each with a single section.
Maybe as an alternative idea, reloadData on the table to only show the sections as a kind of "collapsed all" view on your table (maybe it is possible to even animate this?) which then has one section, containing all sections as row elements. The only extra required would then be a button that will set your table to this state.
I tried to move rows from one section to another, while updating the datasource of course. But this seemed to be mission impossible. Empty cells in between, wrong contents in sections, wrong ordering of sections were the only results I got.