Coder Social home page Coder Social logo

younatics / expandablecell Goto Github PK

View Code? Open in Web Editor NEW
763.0 763.0 122.0 5.47 MB

✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 5

License: MIT License

Objective-C 1.00% Swift 96.00% Ruby 2.81% C 0.19%
cell collapsible expandable ios swift5 tableviewcell

expandablecell's People

Contributors

artemmihelson avatar bagage avatar ben9923 avatar ezefranca avatar hadiidbouk avatar hemangshah avatar kennydust avatar kwongius avatar pikaboo avatar tokijh avatar younatics avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

expandablecell's Issues

Unable to Install Cocoapod

I am getting a "Unable to find a specification for 'ExpandableCell' When I try to install the Cocoapod?

screen shot 2017-09-12 at 11 12 20 am

I'm using:
screen shot 2017-09-12 at 11 14 06 am

I've tried a handful of times

repo out of sync?

Hey, an FYI: the demo contains functions not available is the standard pull. expandAllCells() is used in the demo, but not in the currently available repo.

How to have sections in expandable cell

How to have sections for grouping a set of expandable cell.
can we have sections to existing ExpandableCell segmented with two groups and allow to have expandableCell functionality?

issue with tabbar controller

I have a tabbar controller.
ViewController A with expandable table view inside
View Controller B without. Just empty one

I open A.
opened B
then Open A

expandable table view is not working and crashes

I reproduced this issue with demo app. Just embed in tabbarcontroller instead of navigation controller.
please help

how to collapseAll

Hi @younatics thanks for the neat refactored code!

can you add in the previously requested collapse All and open single expandable cell please?

Cheers

Des

Event for after cell expansion or collapse

The ExpandableDelegate has no method to handle a cell after it is expanded or collapsed.

The method that does exists (didCloseRowAt) is not invoked anywhere that I could find.

Is there a way to capture a cell instance after its open or close methods are invoked, that is, after its isOpen property is set?

That would be especially handful to make changes to the cell layout based on its expanded/collapsed state.

I would suggest the creation of a delegate for the cell itself with methods that could be invoked with its open or close methods execution

Delegate Issue

Hai,
i have problem when i assign expandableCell into expandableCell.
delegate of two table is reference so when i click child table and want to change parent table it didnt change, the action is in expandableCell that i click not the parent table.

Need to expand only One cell at a time.

Is there a way that i could should only one expended cell in table.
Ex:
Let say User selected Cell A it's expended but when User select Cell B, cell A should close and B open automatically.

Arrow issue

Hello, when the tableview becomes bigger than the view itself and there are expandable cells down not visible, their arrow gets affected depending of the visible one. So if i open 3 cells, their arrow is up. When i scroll down and see the fourth cell, its arrow will be as if it was open, but actually it is not.

How do i solve this issue ?

Thanks

Reusability animation problem

Hi,
I have problem with application. Animation is working just fine for first 3 rows that are created on page load. For all other rows i have animation problems. Take a look at video.

https://ufile.io/hmbxz

Any ideas what is problem?

Cells randomly disappearing and titleLabel.text displays wrong text

Hey. I have 11 ExpandableCells and about 50 ExpandedCells. I am initializing it like that:

func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]? {

	`var cells: [ExpandedCell] = []
	for i in 0...platinumProteinMeals[indexPath.row].meals.count - 1 {
		let cell = tableView.dequeueReusableCell(withIdentifier: ExpandedCell.ID) as! ExpandedCell
		print("\(indexPath) | \(i) | \(platinumProteinMeals[indexPath.row].meals[i])")
		cell.titleLabel.text = platinumProteinMeals[indexPath.row].meals[i]
		cell.isHidden = false
		cells.append(cell)
	}
	return cells
}`

The platinumProteinMeals is an array of 11 NDDSections, one section would look like this:
NDDSection(category: "Beef", meals: ["Beef Avocado Salad", "Beef in Chili Sauce", "Beef Soup", "Beef Steak", "Beef Tartar", "Beef with French Beans", "Chilli Lime Beef", "Thai Beef Salad"])

My issue is that the cell randomly disappears (mostly while scrolling) and a wrong meal of themeals array is getting displayed. For example a Turkey meal is being displayed in the Beef ExpandableCell. Any idea how to fix this? Thanks in advance

ExpandableCell protocol

Current ExpandableCell class should considered a standard implementation of a generalized protocol, in order to allow to apply the protocol to UITableViewCell when the developer doesn't want to override ExpandableCell current implementation (for whatever reason).

Wrong indexPath in didSelectExpandedRowAt delegate

Thanks a lot first of all for the awesome library but the indexPath I am getting in expanded cell is of row, the required indexPath in this delegate should start from 0 only then I can get correct value from array of subcategory instead it counts the expanded cell as a row which is not right. Below is my struct, everything works well except the indexPaths are messed up in the expanded cells, please fix. I might be doing something wrong too if that's the case let me know. Thanks!

Also made a video showing wrong indexPath : https://drive.google.com/open?id=10eJUTJSna282Lr_njvcQUAEpG0q7bx3_

The class file can be found here : https://drive.google.com/open?id=1iJfZGFFqK4oLvcIeMqcBZVSLXPkdAy2S

struct MenuItems{
    
    var sectionName:String
    var data:[SideMenuItems]
    
    var numberOfItems: Int {
        return data.count
    }
    
    subscript(index: Int) -> SideMenuItems {
        return data[index]
    }
    
}

struct SideMenuItems{
    
    var name:String
    var image:UIImage
    var subCategoryItems:[SubCategoryItems]?
    
    init(name:String,image:UIImage,subCategoryItems:[SubCategoryItems]) {
        self.name = name
        self.image = image
        self.subCategoryItems = subCategoryItems
    }
    
}

struct SubCategoryItems {
    let subCat: String?
    
    init(subCat: String) {
        self.subCat = subCat
    }
}

tableviewcell not using set constraints

Hi @younatics ,

This library is cool, I want to use it in one of my applications. But I have issue in rendering the tableviewcell. I manage to use a custom tableviewcell but the problem is the constraints I set in the cell is I think overwritten.

Please see screenshot below.

Storyboard cell with costraints.

screen shot 2017-08-12 at 11 23 59 am

Actual result.

screen shot 2017-08-12 at 11 24 11 am

Hoping for your response.

Thank you.

Method with list of table cells being returned not being called on row selection.

Ever since I updated to the newest version, I am unable to expand my expandable cells when I click on the containing row. The selection of the row isn't being triggered and I am not getting asked for the list of table view cells anymore. I don't seem to have this issue with a normal table view and can detect selection and handle it just fine.

Before updating from the 1.1.0 pod version, I was able to actually enter the func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]? method and return my cells; but had an issue where everything would be rendering on top of each other or just in weird locations on the table when more than 1 expandable row was expanded at a time.

Any help would be appreciated. Thanks in advance.

Can't add more than 3 expanded cells

By using

func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]?

and returning more than 3 cells like this:

extension DetailedViewController: ExpandableDelegate {
    func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]? {
        switch indexPath.section {
        case 0:
            switch indexPath.row {
            case 0:
                let cell1 = mDetailedInfoTable.dequeueReusableCell(withIdentifier: StepCountInfoCellHeader.IDENTIFIER) as! StepCountInfoCellHeader
                let cell2 = mDetailedInfoTable.dequeueReusableCell(withIdentifier: StepCountInfoCell.IDENTIFIER) as! StepCountInfoCell
                let cell3 = mDetailedInfoTable.dequeueReusableCell(withIdentifier: StepCountInfoCell.IDENTIFIER) as! StepCountInfoCell
                let cell4 = mDetailedInfoTable.dequeueReusableCell(withIdentifier: StepCountInfoCell.IDENTIFIER) as! StepCountInfoCell
                return [cell1, cell2, cell3, cell4]

causes "Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)" error.

func expandedHeight(at indexPath: IndexPath) -> CGFloat? {
        for expandableData in expandableDatas {
            if let index = expandableData.expandedIndexPaths.index(of: indexPath) {
                return expandableData.expandedHeights[index]     //<-Error occurs here
            }
        }

If this library can only add 3 cells, that's a serious problem.

When I expand the cell then it crashes if one cell is already expended in the following method.

Some time it crashes because filteredExpandedDatas having no object at that time.

func indexPathsWhere(indexPath: IndexPath) -> [IndexPath] {
let filteredExpandedDatas = expandableDatas.filter({ (expandedData: ExpandableData) -> Bool in
return (expandedData.indexPath == indexPath)
})
if filteredExpandedDatas.count > 1 {
fatalError("Something Wrong")
}
return filteredExpandedDatas[0].expandedIndexPaths
}

Expanded Cells not appearing if another cell is expanded

I have a tableview with 2 sections. Each section contains only one row (Completed and ongoing orders). Whenever i click on an expandable cell, it opens normally, but if it is expanded, the other one won't expand unless the first one is closed. I debugged it and it is calling the expandedCellsForRowAt and heightsForExpandedRowAt correctly and is returning all the expanded cells that should appear, but they simply won't appear. Can anyone help me please ? Thanks

Compiler error

Started getting this error after pod install:

Multiple commands produce '/Users/fedor/Library/Developer/Xcode/DerivedData/...-bgbdsrxqedljvpcbxvkmpclubaes/Build/Products/Debug-iphoneos/.../Assets.car':

  1. Target '...' (project '...') has compile command with input '/Users/fedor/.../.../.../Assets.xcassets'
  2. That command depends on command in Target '...' (project '...'): script phase “[CP] Copy Pods Resources”

There are also two warnings:

  1. duplicate output file '/Users/fedor/Library/Developer/Xcode/DerivedData/...-bgbdsrxqedljvpcbxvkmpclubaes/Build/Products/Debug-iphoneos/.../Assets.car' on task: PhaseScriptExecution [CP] Copy Pods Resources /Users/fedor/Library/Developer/Xcode/DerivedData/...-bgbdsrxqedljvpcbxvkmpclubaes/Build/Intermediates.noindex/.../Debug-iphoneos/.../Script-626E2A68364D360141E2BEDF.sh

  2. The app icon set name "AppIcon" is used by multiple app icon sets.

The second one is related to the GoogleMaps pod.

Pod version: 1.3.0.
Swift version: 5.1.
Xcode version: 11.3.1.

How to change arrow image?

The doc says:

For arrow effect
Inherit ExpandableCell when you need arrow effect or change arrow image

open class ExpandableCell: UITableViewCell {
open var arrowImageView: UIImageView!
}

But no matter what I do, I can't do anything to that arrowImageView.
Can anyone tell me how to apply change to that arrowImageView?

Add IBDesignable Delegate

Since we're already mixing storyboards and code, we can just as well also add the ability to set the delegate in the storyboard:

@IBDesignable
extension ExpandableTableView {
    @IBOutlet public var _expandableDelegate: AnyObject? {
        get { return expandableDelegate as AnyObject }
        set { expandableDelegate = newValue as? ExpandableDelegate }
    }
}

In expanded cells, 'SELECTED' mode 'ON' for multiple cells

If I select a expanded cell, it's perfectly alright. But when I go for another selection, both selected cells are being highlighted. So more than one item selection makes this issue. Please let me know if it already has a solution or any way around?

Please enable override func for open and close arrow image

` open func open() {
self.isOpen = true
self.initialExpansionAllowed = false
if highlightAnimation == .animated {
UIView.animate(withDuration: 0.1) {[weak self] in
self?.arrowImageView.layer.transform = CATransform3DMakeRotation(CGFloat(Double.pi), 1.0, 0.0, 0.0)
}
}
}

open func close() {
    self.isOpen = false
    if highlightAnimation == .animated {
        UIView.animate(withDuration: 0.1) {[weak self] in
            self?.arrowImageView.layer.transform = CATransform3DMakeRotation(CGFloat(Double.pi), 0.0, 0.0, 0.0)
        }
    }
}`

Using in a static table view

Hi,

Is it possible to use this library in a static table view?

I'm kind of stuck because for static table views, you don't have to implement the UITableViewDataSource method but this library insists on it.

Crash on reloadData() after changing the number of expandable rows

Hello,

After changing the number of expandable rows in my dataset and call reloadData, the app crashes.
This is caused by fatal error: Index out of range from this line.
After some debugging I think that the problem is about the delegate method func expandableTableView(_ expandableTableView: ExpandableTableView, heightsForExpandedRowAt indexPath: IndexPath) -> [CGFloat]? which is not called for each row after the dataset change.

I'm using:
XCode 9.0.1
Swift 4
ExpandableCell 1.2.0 installed with cocoapods

UPDATE
The crash seems to occur only if the updated dataset have the expandable row open when reloadData() is called. If I call:

self.tableView.closeAll()
self.tableView.reloadData()
self.tableView.open(at: indexPath)

from the func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectRowAt indexPath: IndexPath) method all works as it should, however is not the best solution, because the row is opening, closing and opening again (and the animation will broke).

Crash when opening cells in different sections

Hi. I get a crash when trying to open expandable cells in different sections. Index out of range. Works fine when opening multiple expandable cells in the same section just not in two (or more I'm assuming) different sections. I need this to work without closing the already opened cell. Not sure how to fix this.

Simplest ViewController code below:

import UIKit
import ExpandableCell



class MyTableViewController: UIViewController {

    
    @IBOutlet var tableView: ExpandableTableView!
    
    
    var cell: UITableViewCell {
        return tableView.dequeueReusableCell(withIdentifier: ExpandedButtonCell.ID)!
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        tableView.expandableDelegate = self
        //tableView.openAll()
        tableView.register(UINib(nibName: "NormalExpandableCell", bundle: nil), forCellReuseIdentifier: NormalExpandableCell.ID)
        tableView.register(UINib(nibName: "ExpandedButtonCell", bundle: nil), forCellReuseIdentifier: ExpandedButtonCell.ID)
    }
}


extension MyTableViewController: ExpandableDelegate {
    
    
    // Number of sections
    func numberOfSections(in expandableTableView: ExpandableTableView) -> Int {
        return 2
    }
    
    // Number of rows in section
    func expandableTableView(_ expandableTableView: ExpandableTableView, numberOfRowsInSection section: Int) -> Int {
        return 2
    }
    
    // Cells for row at (returns the main top level cells)
    func expandableTableView(_ expandableTableView: ExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        guard let cell = expandableTableView.dequeueReusableCell(withIdentifier: NormalExpandableCell.ID) else { return UITableViewCell() }
        return cell
    }
    
    // Expanded Cells for row
    func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]? {
        return [cell, cell, cell]
    }
    
    // height for row
    func expandableTableView(_ expandableTableView: ExpandableTableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 100
    }
    
    
    // heights for expanded row at
    func expandableTableView(_ expandableTableView: ExpandableTableView, heightsForExpandedRowAt indexPath: IndexPath) -> [CGFloat]? {
        return [44, 44, 44]
    }

}


// EXPANDABLE CELLS HERE
class NormalExpandableCell: ExpandableCell {
    static let ID = "NormalExpandableCell"
}


class ExpandedButtonCell: UITableViewCell {
    static let ID = "ExpandedButtonCell"

}

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.