finds.dev← search

// the find

nicklockwood/SwipeView

★ 2,624 · Objective-C · NOASSERTION · updated Jan 2020

SwipeView is a class designed to simplify the implementation of horizontal, paged scrolling views on iOS. It is based on a UIScrollView, but adds convenient functionality such as a UITableView-style dataSource/delegate interface for loading views dynamically, and efficient view loading, unloading and recycling.

SwipeView is a UIScrollView wrapper for iOS that adds a UITableView-style dataSource/delegate pattern and view recycling to horizontal (or vertical) paged scrolling. It was built by Nick Lockwood, the same author as iCarousel, and targets the pre-UICollectionView era of iOS development. It is for maintainers of old codebases who can't or won't migrate to UICollectionView.

The dataSource/delegate pattern maps cleanly onto what UICollectionView later standardized, so if you know one you know the other. View recycling via the reusingView parameter in swipeView:viewForItemAtIndex:reusingView: is correctly designed — the caller is responsible for returning the reused view or a new one, same as UITableView. The wrap mode (infinite scrolling) and autoscroll property are genuinely useful features that UICollectionView still doesn't give you for free. The indexOfItemViewOrSubview: method is a practical shortcut for the common problem of identifying which cell a tapped nested control belongs to.

Dead project — last commit in January 2020, targets iOS 7/5.0, written in Objective-C with no Swift support. UICollectionView with a UICollectionViewFlowLayout covers 90% of this library's use cases and has been available since iOS 6, so there is no reason to adopt this in any new project. The reuseIdentifier omission is called out in the README itself: if you have multiple view types you must ignore the recycled view and alloc a new one every time, which defeats the purpose. No XCTest suite — the Tests/ folder is a set of manual Xcode example apps, not automated tests.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →