From e626e946e85a60463f3a80abb21d93d812c5a091 Mon Sep 17 00:00:00 2001 From: Mark Rickert Date: Mon, 24 Aug 2015 09:23:08 -0600 Subject: [PATCH] Adds ability to specify a titleView on sections. --- XLForm/XL/Controllers/XLFormViewController.m | 15 +++++++++++++++ XLForm/XL/Descriptors/XLFormSectionDescriptor.h | 1 + XLForm/XL/Descriptors/XLFormSectionDescriptor.m | 2 ++ 3 files changed, 18 insertions(+) diff --git a/XLForm/XL/Controllers/XLFormViewController.m b/XLForm/XL/Controllers/XLFormViewController.m index 9571e52e..4eb2f85c 100755 --- a/XLForm/XL/Controllers/XLFormViewController.m +++ b/XLForm/XL/Controllers/XLFormViewController.m @@ -704,6 +704,21 @@ -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteg return [[self.form.formSections objectAtIndex:section] title]; } +- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section +{ + return [[self.form.formSections objectAtIndex:section] titleView]; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section +{ + UIView * view = [[self.form.formSections objectAtIndex:section] titleView]; + if(view){ + return view.frame.size.height; + } else{ + return 0.0f; + } +} + -(NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { return [[self.form.formSections objectAtIndex:section] footerTitle]; diff --git a/XLForm/XL/Descriptors/XLFormSectionDescriptor.h b/XLForm/XL/Descriptors/XLFormSectionDescriptor.h index e6964328..9e1f123a 100644 --- a/XLForm/XL/Descriptors/XLFormSectionDescriptor.h +++ b/XLForm/XL/Descriptors/XLFormSectionDescriptor.h @@ -43,6 +43,7 @@ typedef NS_ENUM(NSUInteger, XLFormSectionInsertMode) { @interface XLFormSectionDescriptor : NSObject @property (nonatomic, nullable) NSString * title; +@property (nonatomic, nullable) UIView * titleView; @property (nonatomic, nullable) NSString * footerTitle; @property (readonly, nonnull) NSMutableArray * formRows; diff --git a/XLForm/XL/Descriptors/XLFormSectionDescriptor.m b/XLForm/XL/Descriptors/XLFormSectionDescriptor.m index f0109412..ae7fb123 100644 --- a/XLForm/XL/Descriptors/XLFormSectionDescriptor.m +++ b/XLForm/XL/Descriptors/XLFormSectionDescriptor.m @@ -67,6 +67,7 @@ -(instancetype)init _sectionInsertMode = XLFormSectionInsertModeLastRow; _sectionOptions = XLFormSectionOptionNone; _title = nil; + _titleView = nil; _footerTitle = nil; _hidden = @NO; _hidePredicateCache = @NO; @@ -82,6 +83,7 @@ -(instancetype)initWithTitle:(NSString *)title sectionOptions:(XLFormSectionOpti _sectionInsertMode = sectionInsertMode; _sectionOptions = sectionOptions; _title = title; + _titleView = nil; if ([self canInsertUsingButton]){ _multivaluedAddButton = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeButton title:@"Add Item"]; [_multivaluedAddButton.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];