|
1 | 1 | PDTiledView |
2 | 2 | =========== |
3 | 3 |
|
4 | | -Accordion-style table view, with block-based delegation. |
| 4 | +Accordion-style table view, with block-based delegation. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +CocoaPods soon, but you can drop `PDTiledView.h/.m` into your project for now. |
| 9 | + |
| 10 | +## Usage |
| 11 | + |
| 12 | +Very similar to `UITableView`, but uses `sections` and `tiles` instead of `sections` and `rows`. It also uses blocks instead of protocols for delegation. |
| 13 | + |
| 14 | +### Examples |
| 15 | + |
| 16 | +```objective-c |
| 17 | +PDTiledView *tiledView = ...; |
| 18 | + |
| 19 | +tiledView.numberOfSectionsBlock = ^NSInteger{ return 4; }; |
| 20 | + |
| 21 | +tiledViewdView.numberOfTilesInSectionBlock = ^NSInteger (NSInteger section) { |
| 22 | + return 20; |
| 23 | +}; |
| 24 | +``` |
| 25 | + |
| 26 | +All `sections` and `rows` are just UIControl subclasses, such as UIButton or a custom control of your making. (This may switch to UIView later, not sold on it yet). |
| 27 | + |
| 28 | +```objective-c |
| 29 | +tiledView.controlForSectionBlock = ^UIControl *(NSInteger section) { |
| 30 | + UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 31 | + button.backgroundColor = [UIColor whiteColor]; |
| 32 | + return button; |
| 33 | +}; |
| 34 | + |
| 35 | +tiledView.controlForTileAtIndexPathBlock = ^UIControl *(PDTiledViewDIndexPath indexPath) { |
| 36 | + UIButton *button = [UIButton buttonWithType:UIControlIButtonTypeCustom]; |
| 37 | + return button; |
| 38 | +}; |
| 39 | +``` |
| 40 | + |
| 41 | +There are also optional blocks to further customize how you like. They match up with their `UITableViewDelegate/DataSource` counterparts: |
| 42 | + |
| 43 | +* `heightForSectionControlBlock` |
| 44 | +* `heightForTilesInSectionBlock` |
| 45 | +* `didSelectSectionBlock` |
| 46 | +* `didSelectTileAtIndexPathBlock` |
| 47 | +* `willDisplaySectionBlock` |
| 48 | +* `willDisplayTileAtIndexPathBlock` |
| 49 | + |
| 50 | +## Discussion |
| 51 | + |
| 52 | +The internal implementation does not use `UITableView`s, so while some things are cached, tiles are not loaded on-the-fly and cached as rows are in UITableView. This shouldn't be a big deal unless you are displaying 1,000s of tiles or tiles are extremely rendering intensive. Pull requests are more than welcome to help implement caching, or perhaps to use `UITableView`s internally. |
| 53 | + |
| 54 | +## Contributing |
| 55 | + |
| 56 | +1. Fork it |
| 57 | +2. Create your feature branch (`git checkout -b my-new-feature`) |
| 58 | +3. Commit your changes (`git commit -am 'Added some feature'`) |
| 59 | +4. Push to the branch (`git push origin my-new-feature`) |
| 60 | +5. Create new Pull Request |
| 61 | + |
| 62 | +## Contributors |
| 63 | + |
| 64 | +[Parker Wightman](https://github.com/pwightman) ([@parkerwightman](http://twitter.com/parkerwightman)) |
0 commit comments