kreeger / BDKCollectionIndexView

Gives a UICollectionView the sectionIndexTitles scrub bar that a UITableView gets for almost free.
MIT License
158 stars 29 forks source link

How to use with Auto Layout? #2

Closed mluu510 closed 9 years ago

mluu510 commented 10 years ago

How do I use this indexView with Auto Layout? I don't want to set the frame when I alloc & init it, so the panning feature doesn't work when I do this. How do I overcome this problem? Thank you.

kreeger commented 10 years ago

@mluu510 That's a great question. I think in order to get this to work with Auto Layout, I'll have to do some refactoring; namely, I'd like to make _direction a derived property instead of one set during initialization. That, and I'd like to make some none-frame-based initializers. If you happen to get the chance to open a Pull Request, please do so! It may be a few days until I can get to this (perhaps by this weekend).

mluu510 commented 10 years ago

Look forward to seeing the update. Thanks, Ben!

rinatkhanov commented 9 years ago

Not sure if the problem is solved already, but latest BDKCollectionIndexView works fine with AutoLayout visual format language for me.

I use it like this:

// iv stands for BDKCollectionIndexView object
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[iv]-0-[bottomBar]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(iv, bottomBar)]];

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[iv(w)]-0-|" options:0 metrics:@{@"w" : @30.0f} views:NSDictionaryOfVariableBindings(iv)]];
benshepherd commented 9 years ago

I was able to successfully connect BDKCollectionIndexView via a storyboard IBOutlet and fully constrain it there. I did create a separate "setup" on BDKCollectionIndexView method to handle the other settings in lieu of using "indexViewWithFrame".

kreeger commented 9 years ago

I was able to use this view with auto layout just fine today; closing this issue. Let me know if you're still having issues.