Infinite paging, Smart auto layout, Interface of similar to UIKit.
- swift 2.0
Add the following to your Podfile
:
use_frameworks!
pod "PagingView"
Note: the use_frameworks!
is required for pods made in Swift.
Add the following to your Cartfile
:
github "KyoheiG3/PagingView"
Just add everything in the PagingView.swift
, PagingViewCell.swift
and Constraints.swift
file to your project.
If target is ios8.0 or later, please import the PagingView
.
import PagingView
weak var dataSource: PagingViewDataSource?
- DataSource of
PagingView
. Same asdataSource
ofUICollectionView
.
var pagingMargin: UInt
- Margin between the content.
- Default is
0
.
var pagingInset: UInt
- Inset of content relative to size of
PagingView
. - Value of two times than of
pagingInset
to set for the left and right ofcontentInset
. - Default is
0
.
var infinite: Bool
- Infinite looping enabled flag.
- Default is
true
.
func dequeueReusableCellWithReuseIdentifier(identifier: String) -> PagingView.PagingViewCell
- Used by the
delegate
to acquire an already allocated cell, in lieu of allocating a new one.
func registerNib(nib: UINib?, forCellWithReuseIdentifier identifier: String)
- If a nib is registered, it must contain exactly 1 top level object which is a
PagingViewCell
.
func registerClass<T : PagingView.PagingViewCell>(viewClass: T.Type, forCellWithReuseIdentifier identifier: String)
- If a class is registered, it will be instantiated via
init(frame: CGRect)
.
func reloadData()
- Requery the
dataSource
anddelegate
as necessary.
func invalidateLayout()
- Relayout as necessary.
func numberOfSections() -> Int
func numberOfItemsInSection(section: Int) -> Int
- Information about the current state of the
PagingView
.
func scrollToPosition(position: PagingView.PagingView.Position, indexPath: NSIndexPath? = default, animated: Bool = default)
- To scroll at
Position
. - Cell configure is performed at
NSIndexPath
.
func configureAtPosition(position: PagingView.PagingView.Position, toIndexPath: NSIndexPath? = default)
- Configure cell of
Position
. - IndexPath of cell in the center if indexPath is
nil
.
func pagingView(pagingView: PagingView.PagingView, numberOfItemsInSection section: Int) -> Int
- Paging count number of paging item in section.
func pagingView(pagingView: PagingView.PagingView, cellForItemAtIndexPath indexPath: NSIndexPath) -> PagingView.PagingViewCell
- Implementers should always try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with
dequeueReusableCellWithReuseIdentifier:
.
optional func numberOfSectionsInPagingView(pagingView: PagingView.PagingView) -> Int
- Paging count number of paging item section in
PagingView
. - Default return value is
1
.
optional func indexPathOfStartingInPagingView(pagingView: PagingView.PagingView) -> NSIndexPath?
- IndexPath when
pagingView:cellForItemAtIndexPath:
is first called - Default return value is
0 - 0
ofNSIndexPath
instance.
optional func pagingView(pagingView: PagingView.PagingView, willDisplayCell cell: PagingView.PagingViewCell, forItemAtIndexPath indexPath: NSIndexPath)
optional func pagingView(pagingView: PagingView.PagingView, didEndDisplayingCell cell: PagingView.PagingViewCell, forItemAtIndexPath indexPath: NSIndexPath)
- Called at the display and end-display of.
func prepareForReuse()
- if the cell is reusable (has a reuse identifier), this is called just before the cell is returned from the paging view method
dequeueReusableCellWithReuseIdentifier:
.
Under the MIT license. See LICENSE file for details.