Is it possible to disable floating headers in UITableView with UITableViewStylePlain?
You should be able to fake this by using a custom cell to do your header rows. These will then scroll like any other cell in the table view.
You just need to add some logic in your cellForRowAtIndexPath
to return the right cell type when it is a header row.
You'll probably have to manage your sections yourself though, i.e. have everything in one section and fake the headers. (You could also try returning a hidden view for the header view, but I don't know if that will work)
UITableView with fixed section headers
The headers only remain fixed (floating) when the UITableViewStyle
property of the table is set to UITableViewStylePlain
.
If you have it set to UITableViewStyleGrouped
, the headers will scroll up with the cells (will not float).
Prevent UITableView from scrolling when section header view is dragged
I tried overriding beganTouches etc but they still got passed to the table view, so in the end I abandoned using section header view and inserted the view above the table view. The view had a fixed 220pt height set in the storyboard and an NSLayoutConstraint as IBOutlet so its height could be set to 0 when the view was to be hidden.
How to prevent section from scrolling when dragging cells?
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.
How to highlight/change background color of table view section header while scrolling
Perhabs you can do it with a trick?
Determine if a tableview cell is visible
Just take a look which cells are visible. If a cell of section 2 is visible but no cell of section 1, you know section 2 is at the top.
Action affecting buttons in all TableView Headers
In your header setting, trying doing this instead:
func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// Dequeue with the reuse identifier
let cell = self.massMessageGroupsTableView.dequeueReusableCell(withIdentifier: "MessageGroupTableViewHeader")
let header = cell as! MessageGroupTableViewHeader
header.groupNameLabel.text = messageGroupsMap[section]?.messageGroup.name
header.section = section
header.setComposeButtonImage()
header.delegate = self
let containingView : UIView = UIView()
containingView.addSubview(header)
return containingView
}
iOS: static sectionHeaderView for tableView
It's not possible without using methods like you describe. At least not with the built-in table view.
One reason is that it just doesn't scale to arbitrary content. If you let section headers stack up what should happen when the entire screen is full of headers? How would the user be able to comfortably see and interact with the content under the 6th or 7th section when there is only a few pixels left to show the content because the rest of the screen is taken up by header for sections that the user is obviously not interested in.
You probably want to rethink your UI. Either go with the standard section headers, make some cool light-weight tabs, a custom harmonica control or something entirely different. Maybe even a hierarchical structure depending on the amount of content you want to present.
Presenting TableView with header instead of middle section or footer
In your first tab's viewControllers
, add following code inside viewWillAppear()
method.
let scrollPoint = CGPoint(x: 0, y: 0)
self.tableView.setContentOffset(scrollPoint, animated: false)
Related Topics
Update Badge With Push Notification While App in Background
Swift - Integer Conversion to Hours/Minutes/Seconds
The Simplest Way to Resize an Uiimage
Nsnotificationcenter Addobserver in Swift
Uialertcontroller Custom Font, Size, Color
Attempt to Set a Non-Property-List Object as an Nsuserdefaults
Uploading File With Parameters Using Alamofire
Swift: How to Split Up a [String] Resulting in a [[String]] With a Given Subarray Size
Design For Facebook Authentication in an iOS App That Also Accesses a Secured Web Service
Iphone Navigation Bar Title Text Color
Scrolling Issue on Position Fixed Element on Ios
How to Remove Constraints Programmatically That Is Added from Storyboard
How to Get the Indexpath.Row When an Element Is Activated
Status Bar and Navigation Bar Issue in Ios7
How to Create a Uicolor from a Hex String