Code Monkey home page Code Monkey logo

slexpandabletableview's Introduction

SLExpandableTableView

CI Status Version License Platform

SLExpandableTableView is a UITableView subclass that gives you easy access to expandable and collapsable sections by just implementing a few more delegate and dataSource protocols.

How to use SLExpandableTableView

  • Installation
pod 'SLExpandableTableView'
  • Load the SLExpandableTableView in a UITableViewController
- (void)loadView
{
    self.tableView = [[SLExpandableTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
}
  • Implement the SLExpandableTableViewDatasource protocol
- (BOOL)tableView:(SLExpandableTableView *)tableView canExpandSection:(NSInteger)section
{
    // return YES, if the section should be expandable
}

- (BOOL)tableView:(SLExpandableTableView *)tableView needsToDownloadDataForExpandableSection:(NSInteger)section
{
    // return YES, if you need to download data to expand this section. tableView will call tableView:downloadDataForExpandableSection: for this section
}

- (UITableViewCell<UIExpandingTableViewCell> *)tableView:(SLExpandableTableView *)tableView expandingCellForSection:(NSInteger)section
{
    // this cell will be displayed at IndexPath with section: section and row 0
}
  • Implement the SLExpandableTableViewDelegate protocol
- (void)tableView:(SLExpandableTableView *)tableView downloadDataForExpandableSection:(NSInteger)section
{
    // download your data here
    // call [tableView expandSection:section animated:YES]; if download was successful
    // call [tableView cancelDownloadInSection:section]; if your download was NOT successful
}

- (void)tableView:(SLExpandableTableView *)tableView didExpandSection:(NSUInteger)section animated:(BOOL)animated
{
  //...
}

- (void)tableView:(SLExpandableTableView *)tableView didCollapseSection:(NSUInteger)section animated:(BOOL)animated
{
  //...
}

Sample Screenshots

slexpandabletableview's People

Contributors

bjtitus avatar fraserscottmorrison avatar oliverletterer avatar zwf 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slexpandabletableview's Issues

Changing expand image after collapse

I am using your library in Swift and so far it's working great. I have put the expand image (down arrow) in section which I want to change once the section has collapsed. I have put the expand image using function expandingCellForSection, but there is no similar function for collapsing section.

Any idea how to implement it?

Unable to install through pods

I tried: pod 'SLExpandableTableView'

[!] Error installing SLExpandableTableView
[!] /usr/local/bin/git clone https://github.com/OliverLetterer/SLExpandableTableView.git /var/folders/y7/9q2l4lcs1hx1mg145hm1td6w0000gn/T/d20151207-61737-69xdbj --single-branch --depth 1 --branch 1.3.1

Cloning into '/var/folders/y7/9q2l4lcs1hx1mg145hm1td6w0000gn/T/d20151207-61737-69xdbj'...
fatal: unable to access 'https://github.com/OliverLetterer/SLExpandableTableView.git/': Could not resolve host: github.com

How to keep my sections always opened

Hi Oliver! I'm using your UIExpandableTableView. I want to show my custom table always with expanded sections. can I make my sections always opened? thank you for your answer!

[UITableViewCell setLoading:] Unrecognized selector sent to instance

I have a done a basic setup of a table view of type SLExpandableTableView. What am I missing in my setup?

I implemented

- (UITableViewCell<UIExpandingTableViewCell> *)tableView:(SLExpandableTableView *)tableView expandingCellForSection:(NSInteger)section

This method is where the cell goes to perform setLoading and then it crashes with unrecognized selector error.

I made a custom UITableViewCell subscribing to UIExpandingTableViewCell protocol to try and allay the problem. But that still doesn't work.

Cell Childviews

I am using auto layout. and i have attached 2 images
simulator screen shot oct 14 2015 1 25 55 pm
simulator screen shot oct 14 2015 1 25 59 pm

The first image show non expanded cell with exact layout. now see the second layout after expanding. how to fix this?

sample project

can you include the original sample project? I couldn't figure the proper use of

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

it seems after a section is expanded, the revealed cells are missing the first one (as indexPath.row 0 is used by the "header" expanding cell)

Work in iOS5?

Hi, i try run i iOS5, and i get this message

UIExpandableTableViewSample[76519:207] -[GHCollapsingAndSpinningTableViewCell setExpansionStyle:animated:]: unrecognized selector sent to instance 0x685c070
2011-12-28 07:46:20.943 UIExpandableTableViewSample[76519:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GHCollapsingAndSpinningTableViewCell setExpansionStyle:animated:]: unrecognized selector sent to instance 0x685c070'

Prevent collapse

Hi,

I've a case that when an element of section is selected, i want the header cell not to be collapsed even user touch the cell. Is there an easy way to do it?

Thanks..

Can we use it in Swift4

I am working on a project which is in Swift4. I am very much happy to see this Cocoapod. I want to implement it in my Project So, can you please tell me hoe it will be use in Swift4.

storyboard support

the support is not added by default

I changed the initWithCoder to support it:

  • (id)initWithCoder:(NSCoder *)decoder {
    if ((self = [super initWithCoder:decoder])) {
    self.maximumRowCountToStillUseAnimationWhileExpanding = NSIntegerMax;
    self.expandableSectionsDictionary = [NSMutableDictionary dictionary];
    self.showingSectionsDictionary = [NSMutableDictionary dictionary];
    self.downloadingSectionsDictionary = [NSMutableDictionary dictionary];
    self.animatingSectionsDictionary = [NSMutableDictionary dictionary];
    }
    return self;
    }

Is there any need for the old initWithCoder?

A bug when I set heightForFooterInSection

  • (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
    }

when i set the height for footer in section,there is a bug.Open the first section, the bottom view will no normal.

Uploading 屏幕快照 2016-05-23 下午3.39.40.png…

Background colors of cells are changing while expanding/collapsing

I am having an issue where there background color of the cells are changing while the cells expand/collapse.
I am creating a rounded view by manipulating the layer and i change the layer background color to white so only the rounded area stays white while i set the actual view background color to clear.
Using this, it seems like the layer's white color is being removed when the cells are expanding or collapsing. How can I fix this so the animation includes the cells set colors?

Custom TableViewCells

Hello, designed a custom tableview cell with custom class, i setted up everything like in the example project.

But when I set
self.tableView = [[SLExpandableTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];

I am adding breakpoint to cellForRowAtIndexPath: but properties of cell are always nil.

If SLExpandableTableView is not allocated, cells are populating normally.

Subclassing SLExpandableTableView while implementing delegate and datasource causes problems.

Example:
class TestTableView: SLExpandableTableView, SLExpandableTableViewDelegate, SLExpandableTableViewDatasource
Looks to be the appropriate way to implement UITableView Delegate and DataSource but unable to set them.
testTableView.delegate = testTableView wants me to impossibly cast to SLExpandableDelegate

Or implementing the following also creates an error
class TestTableView: SLExpandableTableView, UITableViewDelegate, UITableViewDataSource

Section Header is animated

I have an SLExpandableTableView that has a couple of sections, but only one section header. When one section expands there is a strange animation where a copy of the section header moves down (then disappears) see screen shots.

The only way Ive managed to fix it is to comment out the following in - (void)expandSection:(NSInteger)section animated:(BOOL)animated in your SLExpandableTableView class

    //[self scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section]
    //            atScrollPosition:UITableViewScrollPositionTop
    //                    animated:animated];

Not sure if this is a bug in your code or if I can do a workaround in mine... any ideas?

PS. I love this class - best expandable table view around!

screen shot 2014-06-13 at 11 41 41 am

screen shot 2014-06-13 at 11 41 59 am

screen shot 2014-06-13 at 11 42 30 am

screen shot 2014-06-13 at 11 42 44 am

screen shot 2014-06-13 at 11 42 58 am

Height for sub row

I want to change height for sub row . but no any method provided for this . would you please suggest how can i change the height of sub row. I want main row height 44 and sub row height 145.

Last Section

Hi, I have a table view with approx 20 sections

when the last section is animated the section header does not move up.

It does not look like the section header has expanded

any ideas?

Something strange with numberOfRowsInSection:(NSInteger)section

Hi

the

  • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

is always called 1 time less than the rowsinSection returned by numberOfRowsInSection

If I return 4 numberOfRowsInSection, the cellForRowAtIndexPath for that section is called only 3 times, always starting at row 1 instead of row 0

Anyone else experienced it?

Expand on NSIndexPath, not section

Perhaps I didn't catch this while reading through your example project, but what if I'd like to make only a few rows within a section expandable? All the datasource methods I'm seeing pass in only the section ...

Cannot conform to the cell protocol with Swift

Hey,

Thank you for an awesome framework!

I am trying to conform to the UIExpandingTableViewCell with Swift, but I'm unable to do so.
I have tried to do it in many ways with initializers etc, as explained here also:
http://stackoverflow.com/questions/27932235/conforming-to-an-obj-c-protocols-property-in-swift

Is it not possible to use the framework in Swift or am I doing it wrong?

Here is the table view cell subclass that I am trying with:

import UIKit
import SLExpandableTableView

class PresentationListItemTVC : UITableViewCell, UIExpandingTableViewCell { 
    var loading: Bool = false

    var expansionStyle: UIExpansionStyle = UIExpansionStyleExpanded

    func setExpansionStyle(style: UIExpansionStyle, animated: Bool) {       
    }   
}

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.