SEssentialsAccordion Class Reference

Inherits from UIView
Declared in SEssentialsAccordion.h
Availability
Related samples AccordionGettingStarted
AccordionHowToMoveSections

Overview

An instance of SEssentialsAccordion (or simply, an accordion) is a means for displaying lists of information, where some of the information is shown, and some of the information is hidden. An accordion is made up of zero or more sections. You can open or close sections to display or hide the information they contain.

Each section is implemented using the SEssentialsAccordionSection class. A section has a header view which is an instance of SEssentialsAccordionSectionHeader, and a content view which is a standard UIView. You can either define a custom view for the header, or you can simply define a title for the section and use the default header view. You supply the content to be displayed in each section.

Each section header contains an instance of SEssentialsAccordionSectionHeaderStyle. This style object manages the appearance of the section.

An accordion must have an object that acts as a datasource. The datasource must adopt the SEssentialsAccordionDataSource protocol. The datasource provides the content for each of the sections when they are displayed in “open” mode.

The content supplied by the datasource is only retained by the Accordion while the content is visible on screen, and will be released when scrolled off screen or the section is closed. It is up to the class adopting the SEssentialsAccordionDataSource protocol to retain content so it can be requested at any time.

An accordion can optionally have an object that acts as a delegate. The delegate must adopt the SEssentialsAccordionDelegate protocol. The delegate is notified when sections are opened, closed, added, deleted or moved.

There are currently two types of accordion:

  • A fixed accordion only shows the contents of one section at a time. When a section is opened, the previously open section is closed. The accordion has a fixed size, and does not scroll.
  • A flexible accordion allows multiple sections to be open at the same time. Its contents can be bigger than its frame. In this case, it will scroll up and down.

Properties

cornerRadius

The default radius which is given to the corners of the accordion. This defaults to 5 points.

@property (assign, nonatomic) CGFloat cornerRadius

Declared In

SEssentialsAccordion.h

dataSource

The datasource provides the content for each of the accordion sections

@property (assign, nonatomic) id<SEssentialsAccordionDataSource> dataSource

Declared In

SEssentialsAccordion.h

delegate

The delegate is notified when sections are opened, closed, deleted or removed.

@property (assign, nonatomic) id<SEssentialsAccordionDelegate> delegate

Declared In

SEssentialsAccordion.h

editable

Whether or not you can swipe to delete a section within the accordion. This defaults to YES.

@property (assign, nonatomic) BOOL editable

Declared In

SEssentialsAccordion.h

editing

Specifies whether or not the ‘move’ and ‘delete’ accessories are visible, allowing movement and deletion. This defaults to NO.

@property (assign, nonatomic) BOOL editing

Declared In

SEssentialsAccordion.h

floatingHeader

Specifies whether the topmost section should slide under its header until pushed off screen. This defaults to YES.

@property (assign, nonatomic) BOOL floatingHeader

Declared In

SEssentialsAccordion.h

lazyLoading

Does the accordion populate section content on loading the section, or on opening the section? Defaults to NO.

@property (assign, nonatomic) BOOL lazyLoading

Discussion

If YES, load content only when section is opened. If NO, eagerly load content when section is created. Cannot be set while the dataSource is set, and will throw an exception if this is attempted. Instead, the dataSource should be set to nil before changing this value.

Declared In

SEssentialsAccordion.h

scrollBounceEnabled

Specifies whether the accordion bounces when it reaches the limit of its scrolling. This defaults to YES.

@property (assign, nonatomic) BOOL scrollBounceEnabled

Declared In

SEssentialsAccordion.h

sections

A shallow copy of the sections which the accordion control contains.

@property (retain, nonatomic, readonly) NSArray *sections

Declared In

SEssentialsAccordion.h

type

The type of Accordion. Defaults to SEssentialsAccordionTypeFlexible.

@property (assign, nonatomic) SEssentialsAccordionType type

Discussion

There are currently two types of accordion.

A fixed accordion only shows the contents of one section at a time. When a section is opened, the previously open section is closed. The accordion has a fixed size, and does not scroll.

A flexible accordion allows multiple sections to be open at the same time. Its contents can be bigger than its frame. In this case, it will scroll up and down.

 typedef enum {
   SEssentialsAccordionTypeFlexible,
   SEssentialsAccordionTypeFixed
 } SEssentialsAccordionType;

Declared In

SEssentialsAccordion.h

Instance Methods

addSection:

Add a single section to the accordion. This will appear at the end (bottom) of the accordion

- (void)addSection:(SEssentialsAccordionSection *)section

Parameters

section

The SEssentialsAccordionSection to be added

Declared In

SEssentialsAccordion.h

addSectionsFromArray:

Add an array of sections to the accordion.

- (void)addSectionsFromArray:(NSArray *)sections

Parameters

sections

The collection of SEssentialsSection objects to be added

Declared In

SEssentialsAccordion.h

applyTheme:

Updates the style of the accordion using the specified theme.

- (void)applyTheme:(SEssentialsTheme *)theme

Declared In

SEssentialsAccordion.h

insertSection:atIndex:

Adds a single section to the accordion at the specified index. This will push the sections below (i.e. with this index or higher) down the accordion.

- (void)insertSection:(SEssentialsAccordionSection *)section atIndex:(NSInteger)index

Parameters

section

The SEssentialsSection to be added

index

The index at which to add the section

Declared In

SEssentialsAccordion.h

moveSectionFromIndex:toIndex:

Moves a section within the accordion

- (void)moveSectionFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex

Parameters

fromIndex

The index where the section can currently be found

toIndex

The index to which the section should be moved

Exceptions

NSInvalidArgumentException

Thrown if the supplied indices are invalid

Declared In

SEssentialsAccordion.h

reloadAllSections

Reloads the contents of all sections, by fetching new content from the dataSource.

- (void)reloadAllSections

Declared In

SEssentialsAccordion.h

reloadSection:

Reloads the content of a section, by fetching the new content from the dataSource.

- (void)reloadSection:(SEssentialsAccordionSection *)section

Parameters

section

The section to reload

Declared In

SEssentialsAccordion.h

removeAllSections

Removes all sections from the accordion. This will reset the content and leave a completely empty accordion.

- (void)removeAllSections

Declared In

SEssentialsAccordion.h

removeSection:

Removes a section from the accordion. The removal will be animated.

- (void)removeSection:(SEssentialsAccordionSection *)section

Parameters

section

The SEssentialsSection to be removed

Declared In

SEssentialsAccordion.h

removeSectionAtIndex:

Removes the section at the specified index from the accordion

- (void)removeSectionAtIndex:(NSInteger)index

Parameters

index

The index of the section to be removed

Declared In

SEssentialsAccordion.h