Cell Containers are subclasses of iAd.View that manage an ordered set of subviews referred to as cells. All cell containers provide a way for one of their cells to come into focus (i.e. become visually prominent) at a time. An example of a cell container is iAd.CarouselView.
Language
- JavaScript
SDK
- iAd 2.1+
Overview
iAd.CellContainer embodies both a protocol—the full set of methods and properties a class must implement in order to qualify as a cell container—and a mixin. The mixin is provided as a convenient way to implement cell container behaviors with very little code.
Classes that mix in iAd.CellContainer must do some additional work in order to fully function as cell containers:
Synthesize a
focusedIndexproperty (the mixin provides getter and setter implementations).Call
initduring the class'sinit()method.Implement the
focusCellAtIndexAnimatedmethod. Because the whole point of cell containers is generally to provide a unique layout, the mixin cannot provide a generic implementation.Optionally implement the
updateLayoutmethod. This method will be called when new cells are added and removed. This is where you can implement custom layout logic.
A very simple class that implements iAd.CellContainer might look like:
iAd.Class({
name: 'CustomContainer',
superclass: iAd.View,
mixins: [iAd.CellContainer],
synthesizedProperties: ['focusedIndex']
});
CustomContainer.prototype.init = function (layer) {
iAd.CellContainer.init.call(this);
this.callSuper(layer);
};
CustomContainer.prototype.focusCellAtIndexAnimated = function (index, animated) {
// custom logic to animate to a new position
};