Git Product home page Git Product logo

accordionview's Introduction

AccordionView

Very simple accordion view in Cocoa Touch.

Usage

AccordionView *accordion = [[AccordionView alloc] initWithFrame:CGRectMake(0, 0, 320, 420)];
[self addSubview:accordion];

// Only height is taken into account, so other parameters are just dummy
UIButton *header1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 0, 30)];
[header1 setTitle:@"First row" forState:UIControlStateNormal];

UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 200)];
// ... add subviews to view1

[accordion addHeader:header1 withView:view1];

// ... add more panels

[accordion setNeedsLayout];

// Set this if you want to allow multiple selection
[accordion setAllowsMultipleSelection:YES];

// Set this to NO if you want to have at least one open section at all times
[accordion setAllowsEmptySelection:YES];

// Remove section at index 1
[accordion removeHeaderAtIndex:1];

Todo

  • Horizontal view
  • Swift bridge

All contributions (no matter if small) are always welcome.

To see how you can help and where to start see Contributing file.

LICENSE

Copyright (C) 2011-2014 Wojtek Siudzinski [email protected], Appsome

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

accordionview's People

Contributors

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

accordionview's Issues

Reanimation on all cells and no scrolling when in horizontal orientation

One thing I noticed when I was using the AccordionView is that when I click on a header, if there are other views open then they re-do the drop-down animation. This normally wouldn't be a big deal but one of my views is a large map so when I click on another header and the map is open, the re-animation on the map is quite obvious. Another thing is that my app needs to support horizontal orientation but the AccordionView is not scrolling with it's built-in scrollview when horizontal. I noticed in your code that there is a TODO comment under if(self.isHorizontal)..? Other than that, it is working quite well and kudos to you. Just a few things to iron out.

Using AccordionView with AutoLayout

Hello,

I set up an AccordionView in Storyboard with AutoLayout and various constraints (Size Classes enabled). When I launch the app the width of the screen and the constraints are not applied to the AccordionView. The titles in the header buttons are centered inside the buttons - as the width is set via constraints the titles are cut off as seen on the screenshot.

ios simulator screen shot 24 aug 2015 22 15 15

Maybe you can help me with that?
Thank you

UIPickerView is rendered before item is expanded

Hello,

I tried to put a UIPickerView in the accordion:

[accordion addHeader:header2 withView:pickerView];

What happens is that the picker view is rendered before the selected item is actually expanded. Try to change

UIView *view2 with UIPickerView in test/ViewController.m to reproduce it.

Best,
Gerasimos

Weird behaviour when accordion is in a UIScrollView

If there are too many sections to fit of the screen, the bottom sections will be hidden and unreachable. The solution is obviously to put the accordion in a UIScrollView. The problem is that if a section is open and at the top of the screen, its header stays at the top of the screen but its view keeps scrolling up. I don't know how to fix this (yet) but I'm looking into it.

Also, if the user touches the header while trying to scroll, the view won't scroll; the user has to scroll by touching the section's view. I don't know how to fix this problem either, and I suspect it's a harder problem, but I will look into it as well.

I attached a screenshot showing the first problem.
uiscrollview bug

AccordionView display issue on iOS 8

Hi,

I have added the AccordionView for one of my project. It loads fine the first time I go to the page but after that if I revisit the page the whole thing just shift further down the page. Not really sure why its doing this. I been having this issue since I updated to iOS 8. Not sure if you can help. Have added images to show the behavior
imagg1
image2

Resize scrollview to accommodate contents

Hi! II'm pretty new to IOS and think this is really great, so thanks a lot!! I have a small problem (or maybe I'm using this incorrectly). The sections (views) I'm adding to the accordion view are quite large (height wise) and I would really like the underlying scroll view to expand in order to fit them. Typically on the lines of scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, newHeightForScrollView), where newHeightForScrollView is the total height of all headers and views. Right now, I cannot completely see the contents of the last section even when I scroll down
skarmavbild 2015-04-23 kl 01 12 54
. A response from you would be really appreciated!! Cheers!

Tapping on the last header collapses its view leaving a white space under it

First off thanks for the cool control. I seem to have found some sorta bug in it.

I have a accordion view 5 headers and a view attached to each of them. Initially it looks like this.

screen shot 2014-01-24 at 11 25 35 pm

Say I tap on the last header and now it looks like this,

screen shot 2014-01-24 at 11 26 42 pm

But then I tap on the orange header again and it's view closes leaving a white space beneath it. Like so,

screen shot 2014-01-24 at 11 28 37 pm

How can I stop this from happening? Is there a property I'm missing out or is this really a bug?

Thank you.

Accordion fails to display items

Hi!

I have a problem with this fantastic control and is that when I put it inside a Tabhost-Tabhost fails when tap on a header and don't display the items instead of that the app crash

AutoLayout Support Using Interface Builder

I am having issue when i create AccordionView using interface builder with constraints. It doesn't expands/compress according to device orientation. Please add support for this.

Close Accordion On Start

Great work, I had no issue implementing/customizing the accordion to my needs. Thank you!

However, there is one problem I can't seem to fix. Is it possible to have the accordion start closed, instead of showing the first view (view1) open on start up? I noticed in my ViewController both "view1" and view2" are set up the same so I've been trying to mess around with some values (selectionIndexes) in AccordionView.m, but haven't had any luck.

Could anyone push me in the right direction here?

Thanks!

--- EDIT ---

Nevermind, you can control this with

if ([selectionIndexes count] == 0) {
[self setSelectedIndex:0];
}

Duh!

Scrollview doesn't fill the screen height on iPhone 6+

Hi, thank you for this very useful library!

I have noticed some strange behavior on iPhone 6+, the scrollview doesn't fill the entire height of the screen. It seems like the accordion gets cropped at some point, leaving a big empty block at the bottom...

Any idea as to where the problem might be? Thanks!

Issue when changing the device orientation

I am facing an issue when device orientation changes. Accordion view is not changing its frame even when we try to add a custom frame in device orientation delegate methods. it remains same.

Sector disappears

  1. When the minValue and maxValue are the same the slider disappears - attached image for demonstration.
  2. In my opinion, the property numbersAfterPoint should be per section not as it is now all or nothing
    screen shot 2015-01-30 at 16 27 28

Calling to didChangeSelection

Hi suda, thank you for this useful control.

I'm trying to call the didChangeSelection method, adding AccordionViewDelegate to my view controller header file, but nothing is happened. When I change the selection, the method is never called.
Do I need to do something more?

I would like to use this for change the accordion view size and show everything.

Thank you.

How to open by default 2 sections(Headers) when view loads?

Hi,

This is very nice tutorial,exactly what I was looking for. But I need to open 2 sections(Headers) when view loads. Right now I am able to open one section when view loads. How can I open 2 or more sections when view loads.

When I added the below lines section one is opened with animation
if (!self.startsClosed && [selectionIndexes count] == 0) {
[self setSelectedIndex:0];
}

In the same way I tried for second section, but it's not working for me. May be I need to make changes some where else.
if (!self.startsClosed &&[selectionIndexes count] == 2) {
[self setSelectedIndex:2];
}

Please help me out. Once again thanks for your great work.

Leak memory on setSelectionIndexes

Yo,

i've a leak memory on the

NSMutableIndexSet *cleanIndexes = [NSMutableIndexSet new];

in the - (void)setSelectionIndexes:(NSIndexSet *)aSelectionIndexes

i don't understand how to fix it.
If i release it after affectation the script doesn't work anymore

Thank's!

Open 1 section at a time

How to make it work, so that only section is opened at a time? If try to open another the previous should close.

Does it have a remove Header

I tried writing my own remove header function but lacking last objects now for closing and opening my rows. Looking for assistance to optimize my code.

  • (void)removeHeader:(id)aHeader withView:(id)aView {
    if ((aHeader != nil) && (aView != nil)) {
    [headers removeObject:aHeader];
    [views removeObject:aView];
    [originalSizes removeObject:[NSValue valueWithCGSize:[aView frame].size]];

    [aView removeFromSuperview];
    [aHeader removeFromSuperview];
    
    /*if ([aHeader respondsToSelector:@selector(addTarget:action:forControlEvents:)]) {
        [aHeader setTag:[headers count] - 1];
        [aHeader addTarget:self action:@selector(touchDown:) forControlEvents:UIControlEventTouchUpInside];
    }
    
    if ([selectionIndexes count] == 0) {
        [self setSelectedIndex:0];
    }*/
    

    }
    }

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.