Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ability to specify a titleView on sections. #522

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions XLForm/XL/Controllers/XLFormViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,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];
Expand Down
1 change: 1 addition & 0 deletions XLForm/XL/Descriptors/XLFormSectionDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions XLForm/XL/Descriptors/XLFormSectionDescriptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ -(instancetype)init
_sectionInsertMode = XLFormSectionInsertModeLastRow;
_sectionOptions = XLFormSectionOptionNone;
_title = nil;
_titleView = nil;
_footerTitle = nil;
_hidden = @NO;
_hidePredicateCache = @NO;
Expand All @@ -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:@(NSTextAlignmentNatural) forKey:@"textLabel.textAlignment"];
Expand Down