iOS: Hide all lines for specific section in UITableView - ios

I have UITableView with two sections, and I want the first section to appear without lines.
is it possible to hide all lines (top and bottom lines and cell separators) for only one section ?

No, separatorStyle is a property of UITableView, so there is no way to change it for specific sections / rows.
But it's not hard to implement yourself, with a custom UITableViewCell subclass

Related

How to disable the scrolling of table view for first Section #iOS

I have two sections in my table view , I want to have scroll enabled for 2nd section and disabled for 1st section , how could I achieve it ?
A UITableView as a whole is a ScrollView so there is no way to only scroll one section. I'd suggest moving what is in the first section into a UIView, then placing a UITableView below that UIView that just has a single section that contains the views you had in the section of the view.
This way the top part will not scroll, but the bottom part will.
A way to workaround it is having 2 UITableViews, one with scrolling disabled while the other has it enabled.
You can disable scrolling on a UITableView on the Attributes inspector while it's selected. There's a whole section on the Scroll View the UITableView has, and in the second subsection there's a toggle for "Scrolling Enabled" which is on by default.
[Edit: I've just seen the other comment, and I'd still recommend 2 UITableViews if you are dealing with dynamic content. If the content from the 1st section isn't dynamic, you may use an UIView as it'll save a lot of time just by not needing to implement 2 UITableViews in a single UIViewController]
#vinay
Try this solution
Take a view at the top of view controller.
Below that view take tableview.
Set table style to Grouped. It makes sections of tableview scrollable.
In your case I would use Section Header for the second section and make that header as customView.
You need to call the following functions:
1) viewForHeaderInSection
if section == 2 {
... customize your header view
}
2) heightForHeaderInSection
if section == 2 {
... set height
}

UITableViews inside UIScrollView

I have read a few posts asking about to put UITableViews inside a ScrollView but mostly this idea is not recommended. The "standard way" to handle this situation as I understand is to use just the UITableView instead of the ScrollView and make the TableView header the UIView to display the content and to use the cell to display any dynamic rows.
However the app I am now developing is a bit different: the first part of the view is some descriptive content that I can use the header view to display. But after that I want to display two scrollable sections potentially with dynamic height. One is a comment section displaying all comments and replies and another is a user section that display any users ever made an offer. This two sections need to be row-based and will be dynamic in height as the content inside them will be different.
So the question is, how should I implement this without putting two UITableViews inside a UIScrollView(My original plan)?
UITableViews inside a ScrollView is not at all recommended as UITableView as its own scrollView as subView.
This two sections need to be row-based and will be dynamic in height
as the content inside them will be different.
Whats wrong with using the delegate for dynamic height for row
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {}
Some Tutorial:
https://www.raywenderlich.com/129059/self-sizing-table-view-cells

can I fix section header view not in the top of UITableView

We know that a plain UITableView will fix its section header view in the top of it. Can we make the section header view not to float in the top of its UITableView, but fix in another position, such as 100 points away from the top of its UITableView?
Any ideals will be appreciated,thanks.
You can add custom view as header to your table view & set the position of tableview from it below 100 points.
Sorry there is no any way to stop it.. But You can do this kind of functionality using the UITableViewCell... take the first cell of section to show section detail and set section height as 0..

Need assistance regarding custom UITableView and custom UITableViewCell

This is screenshot of whatsapp, I have to create a tableview just like this one.
It has space on left side (Dont know top two cell are custom or default with right detail style).
Few cells in between have no separators.
How I am suppose to do same with my uitableview.
Start from iOS 7 left inset of UITalbeViewCell is default. Default value is 15, but you can change it.
This is not a few cells. This is One custom cell. I mean work+main+iPhone it is one cell.

How to prevent section from scrolling when dragging cells?

I want sections would have same behavior as cells when I drag it.
Usual behavior is — when dragging cells, section stands on a same place until it meets other section.
What I want is section drags as usual cell.
The following is from the UITableView Class Reference
Table views can have one of two styles, UITableViewStylePlain and
UITableViewStyleGrouped. When you create a UITableView instance you
must specify a table style, and this style cannot be changed. In the
plain style, section headers and footers float above the content if
the part of a complete section is visible.
If you are going to use the UITableViewStylePlain, I am not sure you can re-engineer the section headers to not float.
An alternative is to use the UITableViewStyleGrouped or use UITableViewStylePlain and instead of using sections, you could separate out your table view by placing the section as another cell.

Resources