Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated blocks delegate for titles (close #16)

Fixed a typo as well
  • Loading branch information...
commit 20373e39e3b97f0c0d7eb289270f563a4ecb1e80 1 parent 04e0f08
@jonsterling jonsterling authored keichan34 committed
View
2  KKGridView/KKBlocksDelegate.h
@@ -18,6 +18,8 @@
@property (copy) NSUInteger (^numberOfItems)(KKGridView *gridView, NSUInteger section);
@property (copy) CGFloat (^heightForHeader)(KKGridView *gridView, NSUInteger section);
@property (copy) CGFloat (^heightForFooter)(KKGridView *gridView, NSUInteger section);
+@property (copy) NSString *(^titleForHeader)(KKGridView *gridView, NSUInteger section);
+@property (copy) NSString *(^titleForFooter)(KKGridView *gridView, NSUInteger section);
@property (copy) UIView *(^viewForHeader)(KKGridView *gridView, NSUInteger section);
@property (copy) UIView *(^viewForFooter)(KKGridView *gridView, NSUInteger section);
View
12 KKGridView/KKBlocksDelegate.m
@@ -14,6 +14,8 @@ @implementation KKBlocksDelegate
@synthesize numberOfItems = _numberOfItems;
@synthesize heightForHeader = _heightForHeader;
@synthesize heightForFooter = _heightForFooter;
+@synthesize titleForHeader = _titleForHeader;
+@synthesize titleForFooter = _titleForFooter;
@synthesize viewForHeader = _viewForHeader;
@synthesize viewForFooter = _viewForFooter;
@@ -40,6 +42,16 @@ - (NSUInteger)numberOfSectionsInGridView:(KKGridView *)gridView
return _numberOfSections ? _numberOfSections(gridView) : 1;
}
+- (NSString *)gridView:(KKGridView *)gridView titleForHeaderInSection:(NSUInteger)section
+{
+ return _titleForHeader ? _titleForFooter(gridView,section) : @"";
+}
+
+- (NSString *)gridView:(KKGridView *)gridView titleForFooterInSection:(NSUInteger)section
+{
+ return _titleForFooter ? _titleForFooter(gridView,section) : @"";
+}
+
- (CGFloat)gridView:(KKGridView *)gridView heightForHeaderInSection:(NSUInteger)section
{
return _heightForHeader ? _heightForHeader(gridView,section) : 25.0;
View
8 KKGridView/KKGridView.m
@@ -1076,7 +1076,9 @@ - (UIView *)_viewForHeaderInSection:(NSUInteger)section
if (_dataSourceRespondsTo.viewForHeader) {
headerView = [_dataSource gridView:self viewForHeaderInSection:section];
- } else if (_dataSourceRespondsTo.titleForHeader) {
+ }
+
+ if (!headerView && _dataSourceRespondsTo.titleForHeader) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor darkGrayColor];
label.textColor = [UIColor lightTextColor];
@@ -1096,7 +1098,9 @@ - (UIView *)_viewForFooterInSection:(NSUInteger)section
if (_dataSourceRespondsTo.viewForFooter) {
footerView = [_dataSource gridView:self viewForFooterInSection:section];
- } else if (_dataSourceRespondsTo.titleForHeader) {
+ }
+
+ if (!footerView && _dataSourceRespondsTo.titleForFooter) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor colorWithRed:0.772f green:0.788f blue:0.816f alpha:1.f];
label.textAlignment = UITextAlignmentCenter;
Please sign in to comment.
Something went wrong with that request. Please try again.