• Stars
    star
    159
  • Rank 235,916 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 12 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gives a UICollectionView the sectionIndexTitles scrub bar that a UITableView gets for almost free.

BDKCollectionIndexView

An index-title-scrubber-bar, for use with a UICollectionView or as a replacement for the one provided by a UITableView. Gives a collection/table view the index title bar for -sectionIndexTitles that a UITableView gets for (almost) free. A huge thank you to @Yang from this Stack Overflow post, which saved my bacon here.

gif

Usage

To install it via CocoaPods, just drop this line in your Podfile:

pod 'BDKCollectionIndexView'

And then run pod install, naturally. After that, create an instance of BDKCollectionIndexView, and add it as a subview of whatever view contains your tableView or collectionView (but not the tableView or collectionView itself). Then assign it a width value of 28 (or height, if you're using it as a horizontal index view). Attach whatever other layout constraints you see fit!

override func viewDidLoad() {
    super.viewDidLoad()

    let indexWidth = 28
    let frame = CGRect(x: collectionView.frame.size.width - indexWidth,
        y: collectionView.frame.size.height,
        width: indexWidth,
        height: collectionView.frame.size.height)
    var indexView = BDKCollectionIndexView(frame: frame, indexTitles: nil)
    indexView.autoresizingMask = .FlexibleHeight | .FlexibleLeftMargin
    indexView.addTarget(self, action: "indexViewValueChanged:", forControlEvents: .ValueChanged)
    view.addSubview(indexView)
}

func indexViewValueChanged(sender: BDKCollectionIndexView) {
    let path = NSIndexPath(forItem: 0, inSection: sender.currentIndex)
    collectionView.scrollToItemAtIndexPath(path, atScrollPosition: .Top, animated: false)
    // If you're using a collection view, bump the y-offset by a certain number of points
    // because it won't otherwise account for any section headers you may have.
    collectionView.contentOffset = CGPoint(x: collectionView.contentOffset.x,
        y: collectionView.contentOffset.y - 45.0)
}

Then, when you have the section index titles (rather, the label values that you want to appear on the index bar), assign that array to the index bar instance's indexTitles value.

self.indexView.indexTitles = self.resultsController.sectionIndexTitles

You can modify backgroundColor and touchStatusBackgroundColor property to change the background color of the "touch status view" that appears when the view is touched. Use tintColor of BDKCollectionIndexView instance to change the color of text labels.

Again, big thanks to @Yang for the solution on which this is based.

Please...

If you use this in your project, drop me a line and let me know! I'd love to hear about it. You can hit me up via email, on Twitter, or carrier pigeon.

Contact

Contributors

More Repositories

1

BDKNotifyHUD

An animated UIView for displaying a temporary "bezel" notification, mid-screen.
Objective-C
92
star
2

base16-xcode

A Base16 build template for Xcode.
Mustache
44
star
3

BDKGeometry

A set of helper functions I've been using in various XCode projects, abstracted for great good!
Objective-C
29
star
4

python-rdio

Unofficial Python wrapper for Rdio's web services API. Complete with models for all Rdio objects and OAuth support.
Python
18
star
5

BDKAutomatic

An Objective-C interface to the Automatic REST API.
Objective-C
12
star
6

etcetera

Educational Technology Center Equipment Tracking and Enhanced Report Authoring. This desperately needs some refactoring love, as it was my first real-deal Django project (and it was done *somewhat* willy-nilly).
Python
9
star
7

benlight

My Twilight-based vim color scheme.
Vim Script
7
star
8

marshmallow

An upcoming Campfire client for iPhone, iPad, and iPod Touch.
Objective-C
7
star
9

IFBKThirtySeven

A collection of API adapters for 37signal's various services. Currently only contains adapters for Campfire and Launchpad.
Objective-C
5
star
10

RdioSharp

Unofficial but totally functional .NET Framework extension for use with the Rdio API.
C#
4
star
11

b-greek

Growl styles created by me, pretty much for me.
4
star
12

BDKKit

An abstraction full of categories and other helpers I've come to use between iOS / OS X projects.
Objective-C
4
star
13

jsonapi-ruby

A Ruby interface to the Bukkit/Minecraft JSONAPI plugin.
Ruby
3
star
14

rdio-ichat

A python script that talks to Rdio's API and updates your iChat status accordingly.
Python
2
star
15

swift4-olt-data-logger

Data Logger assignment for Swift 4 Online Live Training.
Swift
2
star
16

robby

Robby is a Ruby-based Campfire bot, inspired by Hubot.
Ruby
1
star
17

bukkit-experience

Java
1
star
18

kreegerator

A set of generators for various projects I work on.
Ruby
1
star
19

kreeger.github.com

1
star
20

liftoff-templates

For use with Thoughtbot's excellent liftoff tool.
Objective-C
1
star
21

potato

Ruby
1
star
22

BDKUntappd

An AFNetworking-based adapter to communicate with the Untappd API.
Objective-C
1
star
23

pngnq

A Ruby wrapper around pngnq's command-line interface.
Ruby
1
star
24

BDKLog

A simple log formatter for CocoaLumberjack.
Objective-C
1
star