Skip to content

Commit 5dd0c5a

Browse files
committed
Setting minimum deployment target to 5.1, fixed some naming inconsistencies, and created a README.
1 parent 93f8676 commit 5dd0c5a

File tree

5 files changed

+66
-7
lines changed

5 files changed

+66
-7
lines changed

PDTiledView.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@
407407
GCC_PRECOMPILE_PREFIX_HEADER = YES;
408408
GCC_PREFIX_HEADER = "PDTiledView/PDTiledView-Prefix.pch";
409409
INFOPLIST_FILE = "PDTiledView/PDTiledView-Info.plist";
410-
IPHONEOS_DEPLOYMENT_TARGET = ":w";
410+
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
411411
PRODUCT_NAME = "$(TARGET_NAME)";
412412
WRAPPER_EXTENSION = app;
413413
};
@@ -419,7 +419,7 @@
419419
GCC_PRECOMPILE_PREFIX_HEADER = YES;
420420
GCC_PREFIX_HEADER = "PDTiledView/PDTiledView-Prefix.pch";
421421
INFOPLIST_FILE = "PDTiledView/PDTiledView-Info.plist";
422-
IPHONEOS_DEPLOYMENT_TARGET = ":w";
422+
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
423423
PRODUCT_NAME = "$(TARGET_NAME)";
424424
WRAPPER_EXTENSION = app;
425425
};

PDTiledView/PDTiledView/PDTiledView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PDIndexPath PDIndexPathMake(NSInteger section, NSInteger tile) {
2929
@property (strong, nonatomic) NSInteger (^numberOfSectionsBlock)();
3030
@property (strong, nonatomic) NSInteger (^numberOfTilesInSectionBlock)(NSInteger section);
3131
@property (strong, nonatomic) UIControl* (^controlForSectionBlock)(NSInteger section);
32-
@property (strong, nonatomic) UIControl* (^controlForIndexPathBlock)(PDIndexPath indexPath);
32+
@property (strong, nonatomic) UIControl* (^controlForTileAtIndexPathBlock)(PDIndexPath indexPath);
3333

3434
#pragma Optional Blocks
3535
// Default is the width of this PDTiledView, so it will be square

PDTiledView/PDTiledView/PDTiledView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ - (void) selectSection:(NSInteger)section animated:(BOOL)animated {
141141
tiledScrollView.contentSize = contentSize;
142142

143143
for (NSInteger i = 0; i < numberOfTiles; i++) {
144-
UIControl *control = _controlForIndexPathBlock(PDIndexPathMake(section, i));
144+
UIControl *control = _controlForTileAtIndexPathBlock(PDIndexPathMake(section, i));
145145

146146

147147
CGRect frame = CGRectZero;

PDTiledView/PDViewController.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ - (void)viewDidLoad
4444

4545
};
4646

47-
_tiledView.controlForIndexPathBlock = ^UIControl *(PDIndexPath indexPath) {
47+
_tiledView.controlForTileAtIndexPathBlock = ^UIControl *(PDIndexPath indexPath) {
4848
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
4949
button.backgroundColor = [self randomColor];
5050
button.layer.borderColor = [[UIColor blackColor] CGColor];
5151
button.layer.borderWidth = 1;
52-
button.titleLabel.text = [NSString stringWithFormat:@"%@", @(indexPath.tile)];
5352
return button;
5453
};
5554

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,64 @@
11
PDTiledView
22
===========
33

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

Comments
 (0)