laurentiuungur / luexpandabletableview Goto Github PK
View Code? Open in Web Editor NEWA subclass of UITableView with expandable and collapsible sections
License: MIT License
A subclass of UITableView with expandable and collapsible sections
License: MIT License
Hi,
How should I collapse the previous cells when I expand a new one ?
Since the ExpandableSectionHeader
section property is set on viewForHeaderInSection
.
Upon dynamically deleting a section the section property is invalid.
How to collapse previously expanded section on selection of new section?
In Order to fetch dynamic data , I made an api call inside this method -
func expandableTableView(_ expandableTableView: LUExpandableTableView, numberOfRowsInSection section: Int) -> Int {
let TappedIndex = section
print("TappedIndex : \(TappedIndex)")
print(self.SubcategoryData[section]["entity_id"])
self.SubCatId = self.SubcategoryData[section]["entity_id"].stringValue
self.ApiCallforSubSubCategoryData()
return self.SubSubCategoryData.count
}
func ApiCallforSubSubCategoryData() {
let parameters: Parameters = ["cat_id":self.SubCatId]
print(parameters)
self.strRequestFor = "SubSubCategory"
self.view.makeToastActivity(.center)
APIClient.sharedInstance.requestPOSTURL(baseUrl+"MySub?", params: parameters, headers: nil, success:{ (json) in
self.view.hideToastActivity()
self.ApiResponse(data: json)
}, failure: { (error) in
//error code
self.view.hideToastActivity()
alertView = UIAlertController(title: "Error Occurred", message: "Unable to connect to server", preferredStyle: .alert)
alertView.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self.present(alertView, animated:true, completion:nil)
print(error)
})
}
func ApiResponse(data: JSON) {
if (data[0]["code"] == 1) {
if(strRequestFor == "SubCategory"){
self.SubcategoryData = data[0]["result"]
self.LoadData()
}
else if(strRequestFor == "SubSubCategory"){
print(data)
self.SubSubCategoryData = data[0]["result"]
// self.LoadData()
}
}
}
But control will execute return statement before API could get Response.
If I call this api function with callback even in that case it will execute default return statement first and not the one which is inside callback.
How to achieve this?
there is no delegate methods for footer
If the list is scrollable then getting animation issue with expanded cell.
Hi!,well when i tap a headercell i reall need that tha section scrolls at top of expandableTableView and expand its subviews
I can barely archieve this by doing:
self.mExpandableTV.scrollToRow(at: indexPath, at: .none, animated: true)
but when the header scrolls at top it expands its subviews at the bottom of the list (i want it to show the firs t item), i cant find a way of solving this
So? Is there a function that "center " the header tapped at top of tableView?
I would like to have all the sections expanded when I load the tableview, is it possible?
I updated to latest version and got this errors :
/Pods/LUExpandableTableView/Sources/LUExpandableTableView.swift:277:13: Cannot use mutating member on immutable value: 'expandedSections' setter is inaccessible
/Pods/LUExpandableTableView/Sources/LUExpandableTableView.swift:279:13: Cannot use mutating member on immutable value: 'expandedSections' setter is inaccessible
in this function:
public func expandableSectionHeader(_ sectionHeader: LUExpandableTableViewSectionHeader, shouldExpandOrCollapseAtSection section: Int) {
if expandedSections.contains(section) {
expandedSections.remove(section) // <---------------- Here
} else {
expandedSections.insert(section) // <---------------- and Here
}
beginUpdates()
reloadSections(IndexSet(integer: section), with: animation)
endUpdates()
let sectionHeaderRect = rectForHeader(inSection: section)
if !bounds.contains(sectionHeaderRect) {
scrollRectToVisible(sectionHeaderRect, animated: true)
}
}
Swift 3.* , Xcode 9.0, iOS 11, LUExpandableTableView 3.0.0
func scrollViewDidScroll(_ scrollView: UIScrollView) {
print(scrollView.contentOffset.y)
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
print("scrollViewDidEndDragging")
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
print("scrollViewDidEndDecelerating")
}
I want to implement Sicky Header but I can't call ScrollViewDelegate methods.
I'm getting "Cannot use mutating member on immutable value: 'expandedSections' setter is inaccessible" error in library
Hi, i have another tableview, inside cell that is expanded.
The problem is, when i expand header for the first time, its returning estimated row height, of the second tableview.
If i collapse it, then expand it one more time - everything workis fine.
So how can i make it works, for the first expand ?
func expandableTableView(_ expandableTableView: LUExpandableTableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if insideCell.unselectableTableView != nil {
return insideCell.unselectableTableView.contentSize.height
} else {
return 55
}
}
This whats returning on your Framework. This is what i have in tableview, that inside first cell 👍
unselectableTableView.estimatedRowHeight = 55
unselectableTableView.rowHeight = UITableViewAutomaticDimension
Please help, strugling for 3 days, tried different methods, including set all to UITableViewAutomaticDimension, didn't work.
Even found workaround, to expand and collapse header, in wievwillappear, but anyway animation is still visible for human eye.
Hey,
First and foremost, thanks for that great lib. I just have a little problem which i hope you could fix.
https://puu.sh/xTQfo/fcc5272bec.png
When i click on the header, sub cells appear but before having the same background color than the header background color, the background color of each cells are white.
It resides in a very ugly effect when i expand the header. Could you fix that ?
Thanks
I wish to dynamically load my rows after having expanded a section, to do so I need to be informed when a section has been expanded.
Is there a delegate that inform us when all sections are collapse or expanded?
How to expand section?
because when I click its not expanded
and cellforrow not called
Please will you add the @objc attribute to provide objective support
when I click section then expand table but I want to click header then opened cell and header cell colour will be same.
Want to achieve something like this-
I want to reload cells on cell click in order to check the box and fetch the checkbox values.
In DidSelectRowAtIndexPath i am doing like this-
func expandableTableView(_ expandableTableView: LUExpandableTableView, didSelectRowAt indexPath: IndexPath) {
print("Did select cell at section \(indexPath.section) row \(indexPath.row)")
let cell = expandableTableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier, for: indexPath) as! FilterTableCell
self.expandableTableView.beginUpdates()
cell.setSelected(true, animated: true)
self.expandableTableView.reloadRows(at: [indexPath], with: .automatic)
self.expandableTableView.endUpdates()
}
and Inside Cell for row at index path if i am checking if cell is selected or not. It always says not selected-
func expandableTableView(_ expandableTableView: LUExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = expandableTableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) as? FilterTableCell else {
assertionFailure("Cell shouldn't be nil")
return UITableViewCell()
}
if cell.isSelected{
print("selected")
}
else{
print("not selected")
}
cell.label.text = "\(self.FilterValueArray.object(at: indexPath.row))" + " (" + "\(self.FilterCountArray.object(at: indexPath.row))" + ")"
return cell
}
BTW if i am checking like this inside CellForRowAtIndexPath() it shows cell is selected but with this i can't access my Cell properties.
if let cell = expandableTableView.cellForRow(at: indexPath) {
if cell.isSelected {
print("This cell is selected")
// cell.button.setImage(UIImage(named: "CheckboxUnchecked"), for: .normal)
}
else{
print("This Cell is not selected")
// cell.button.setImage(UIImage(named: "CheckboxUnchecked"), for: .normal)
}
}
So could u assist me on this that how can i work out my cell selection issue?
I wish to implement:
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
However I cannot do so since LUExpandableTableView
absorbs all delegates
As you have made the height related delegate methods non-optionals, how to set their heights dynamically?
For a normal UITableView, we could use following methods:
tblView.rowHeight = UITableViewAutomaticDimension
tblView.sectionHeaderHeight = UITableViewAutomaticDimension
tblView.estimatedRowHeight = 44
Could not find module 'LUExpandableTableView' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios
Hello! Thanks firstly for this amazing library.
I have one problem with it. When I have pretty tall headers and cells, I encounter some really nasty flickering & weird repositions for the header. I uploaded a video here.
Any solution?
I want to perform some operation of tableViewCells which requires Selection & Deselction of cells (like click on checkbox and uncheck it).
For that it requires didDeSelectRowAtIndexPath().
Could u add this delegate function or could you assist me on this?
When the table is scrolled then more than one section is expanded. I don´t know why but in my table when I have a section expanded and then I scroll down to see more, other section is expanded automatically and throw an error on this library method:
public func expandableSectionHeader(_ sectionHeader: LUExpandableTableViewSectionHeader, shouldExpandOrCollapseAtSection section: Int).
I attached the screenshot of the error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.