Giter Site home page Giter Site logo

laurentiuungur / luexpandabletableview Goto Github PK

View Code? Open in Web Editor NEW
125.0 10.0 19.0 2.26 MB

A subclass of UITableView with expandable and collapsible sections

License: MIT License

Swift 97.07% Ruby 2.93%
cocoapods collapsible-sections xcode ios tableview expandable swift cocoa pod collapsible

luexpandabletableview's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luexpandabletableview's Issues

How to Fetch Dynamic Data when Tapping on Section Header?

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?

Centering header cell when tapped

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?

Cannot use mutating member on immutable value: 'expandedSections' setter is inaccessible

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

I can't call ScrollViewDelegate methods

    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.

Cell Height

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.

Problem with cell background colour

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

Overlapping issue

Hi, I facing this problem when I not using table view controller. It will appear like this
simulator screen shot 21 aug 2017 10 07 32 am

How should I solve this?

Maybe simple problem

How to expand section?
because when I click its not expanded
and cellforrow not called

UiTableViewCellSelection seems not working for LUExpandableTableView.

Want to achieve something like this-
screen shot 2018-10-10 at 1 31 52 pm

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?

How to set cell and section height dynamically?

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

Not working on simulator

Could not find module 'LUExpandableTableView' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios

Flickering issues

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?

Unavailability of "didDeSelectRowAt indexPath" function

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?

Scroll and expandable table

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.

image uploaded from ios 8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.