Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
narasimhanallamsetty opened this issue Jun 25, 2015 · 4 comments
Open

Comments

@narasimhanallamsetty
Copy link

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.

@suda
Copy link
Member

suda commented Jun 26, 2015

Hi @narasimhanallamsetty

first you have to allow multiple selections:

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

and then you can set setSelectionIndexes:

[accordion setSelectionIndexes:indexesToOpen];

@narasimhanallamsetty
Copy link
Author

Hi @suda

Thanks for the reply, I have set [accordion setAllowsMultipleSelection:YES]; in my ViewController.m

But Where I should call [accordion setSelectionIndexes:indexesToOpen]; code, I am not sure. Could you explain more. Please bear with me. Thank you.

@suda
Copy link
Member

suda commented Jun 26, 2015

You should call setSelectionIndexes where you initialise accordion. indexesToOpen is a NSIndexSet instance containing indexes you want to be opened.

@narasimhanallamsetty
Copy link
Author

accordion = [[AccordionView alloc] initWithFrame:CGRectMake(10, 60, 300, [[UIScreen mainScreen] bounds].size.height-30)];

[containerView addSubview:accordion];

[accordion setSelectionIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)]];

If I did any mistake please let me know. still it's not working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants