Shows bottom section of table view at visible view - ios

I know the title is confusing. So I explain what I expect.
I have 3 sections in my table view. The first section has one or more rows. And second and third sections has only one row. When the first section has more than 4 rows the next sections going to be visible by scrolling table view bottom.
But I need these sections be visible in this case.
Actually I need show these sections at the bottom of the visible frame when first section has more than 4 rows!
Is it possible ?

The thing you can do it to display only the 3 first rows of the first section and then when the user starts scrolling, you add the additional cells to the first section while he is scrolling until you've added all of your cell.
Do the opposite when scrolling to top.

You can use two different TableView instead of one.
declare first TableView with only one section & seconds TableView with two section with one row each.
for that you need to use UIViewController instead of UITableViewController.
in this way your bottom TableView Cell always stay visible while first TableView can scroll with more cells.

Related

Two UITableViews in one scrollview

I want to make UIViewController, which has 2 UITableViews - one is content tableview, second is an comments section tableview.
Basically, It's an detail product VC, which has own UITableView for own content and second UITableView will be CommentsVC tableview.
Problem is that, I want to get them like one whole tableView (scroll together) (like 2 section style).
My first idea was to create UIScrollView container, which contains both UITableViews, but I think that there will be problem with reusing cells.
Example sketch
When you take tableview inside scrollview it creates problem in scrolling i.e conflicting scrolls of both scrollview and tableview as UIScrollview is superview of UITableView .
So it's better to take one UITableView with different section. One Section for your content and another section for comments.

TableView reload not setting UITableView section height

I am working on a UITableView which has 2 sections, both of which have exactly 1 row which is a custom cell. This custom cell has a collection view which is used to display various products.
Specific to my issue, the two collection views have 6 cells(three rows in the collection view). However when I load the page, the second section only displays 4 cells (two rows in the collection view). I am using UITableViewAutomaticDimension for the tableview which has the cells that contain these collection views.
I have tried using setLayoutNeeded and layoutIfNeeded, I am calling reload data on the tableView in a number of places. I am reloading the second section specifically as well. However the only way the cell's dimensions get fixed is if I scroll down to the second section, then scroll up to the first and then go back to the second.
I have been stuck on this for the past 3 days and absolutely any help would be greatly appreciated.
However the only way the cell's dimensions get fixed is if I scroll
down to the second section, then scroll up to the first and then go
back to the second.
According to this, I think you should reload your collection views firstly. And then reload your table view.

UITablleView insert rows animated without scrolling

I have implemented a TableView with multiple sections and a section headers and section footers in each section. When the user tapes one cell more cells are inserted in an animated fashion.
To implement this I update the data model and call
[self.tableView insertRowsAtIndexPaths:addedIndexPaths withRowAnimation:(UITableViewRowAnimationTop)];
On the top rows this works as expect: The aded rows animate and the content ofset of the tableview is constant. On the last cell the tableview scrolls either to the top of the previous section or to the top of the footer of the previous section.
Why does the tableview scroll when I insert rows? How can I prevent that scrolling while keeping the animation?
The main way around this is to not use insertRowsAtIndexPaths. Instead try using reloadSections in order to keep the animations.

Making section in UITableView closed(with 0 cells) after scrolling away and returning to it

I have a UITableView where I have section headers that can be tapped to expand or collapse the section. In my particular example each section only has one row, which is either visible (section expanded) or hidden (section collapsed). (I have a UITapGestureRecognizer on the section headers which I use to expand or collapse the sections) here the process of my actions:
I'm tap on the section (this is UITableViewHeaderFooterView custom view) and i see the cell that appears under the section header. At this moment everything is going OK. But when i scrolling down my tableview, cell goes behind header (like in Contacts application , header is first letter of contact). And finally when i scroll enough to don't see that section with that cell on, and when i scroll up - to return to my display that section - i want to make this section automatically known that when i return(from scrolling away that section from view) to it - i want that section already was closed with 0 cells in it.
Maybe i must use -(void) prepareForReuse at my custom UITableViewHeaderFooterView, or scroll methods ? or any tableView methods?
Thank you
You can implement the scroll view delegate methods and use them to check the scroll position (contentOffset) and / or the visible cells (indexPathsForVisibleRows). Once you know that you can collapse any sections that are no longer visible. You should probably use one of the scroll methods that means the scrolling has stopped (maybe scrollViewDidEndScrollingAnimation:) because changing the table view content size (which changing the number of rows will do) during a scroll animation could cause it to stop abruptly.

UITableView sections to always stay within view

I have a UITableView with 3 sections:
section 1:
the header title of this section is "Players" and the cotent is exactly 1 cell containing a horizontal list of 1-4 players names.
section 2:
the header title of this section is "Rounds" and the content is X cells each containing a horizontal list of each respective players score for round X.
section 3:
the header title of this section is "Totals" and the content is exactly 1 cell containing the sum of each player's round scores.
Right now, all these sections scroll as section 2 expands with new rounds, but I want to always keep section 1 at the top of the screen, and have section 3 right below section 2, until it expands down to the bottom of the screen and then stop and stay there.
I guess I could do this with 3 separate table views inside a UIView but that seems kind of convoluted and I section 3 wouldn't stay right below section 2 until it expanded to the bottom of the screen; it would just always be at the bottom...
Is there a way to keep a table section/row always visible, and have the others still scrollable?
Use 3 UITableViews as you discussed, and just animate the position of the Third tableview to move it down each time you add a cell to tableView 2, until it reaches the bottom of the screen then just leave it there. (Also you will need to expand the height of tableView 2 as you add elements to it.)
Otherwise, like Cyrille said, there is no way to implement that with one tableview only.
Not with the standard UITableView implementation, no.

Resources