Skip to content

Commit 60c197e

Browse files
committed
Added optional UITableView property.
* Added a UITableFView property and set it up if the subclass did not already do so. * Documented headers * Included MIT license information with headers * Updated Example App
1 parent 4fe220e commit 60c197e

File tree

4 files changed

+67
-21
lines changed

4 files changed

+67
-21
lines changed

Example/Classes/CLViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
#import "CLTableWithFooterViewController.h"
1010

11-
@interface CLViewController : CLTableWithFooterViewController <UITableViewDataSource>
11+
@interface CLViewController : CLTableWithFooterViewController
1212

1313
@end

Example/Classes/CLViewController.m

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ - (void)viewDidLoad
1818

1919
self.footerImage = [UIImage imageNamed:@"Footer.png"];
2020

21-
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
22-
tableView.delegate = self;
23-
tableView.dataSource = self;
24-
tableView.backgroundColor = [UIColor colorWithRed:237/255.0 green:97/255.0 blue:97/255.0 alpha:1.0];
25-
tableView.separatorColor = [UIColor clearColor];
26-
27-
[self.view addSubview:tableView];
21+
// Customize table view
22+
self.tableView.backgroundColor = [UIColor colorWithRed:237/255.0 green:97/255.0 blue:97/255.0 alpha:1.0];
23+
self.tableView.separatorColor = [UIColor clearColor];
2824
}
2925

26+
#pragma mark UITableView DataSource
27+
3028
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
3129
{
3230
return MAX_CELL_COUNT + 1;

Src/CLTableWithFooterViewController.h

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
//
2-
// CLTableWithFooterViewController.h
3-
//
4-
// Copyright (c) 2013 Chris Ledet
5-
//
1+
/*
2+
CLTableWithFooterViewController.h
63
7-
@interface CLTableWithFooterViewController : UIViewController <UITableViewDelegate>
4+
Copyright (c) 2013 Chris Ledet
5+
Licensed under the MIT license <http://opensource.org/licenses/MIT>
86
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
10+
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or substantial portions
13+
of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
16+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
18+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
IN THE SOFTWARE.
20+
*/
21+
22+
@interface CLTableWithFooterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
23+
24+
/* A handy UITableView already setup on load if you don't assign one yourself */
25+
@property (nonatomic, strong) UITableView *tableView;
26+
27+
/* Required UIImage for the footer. It will remain move as you scroll until you reach the bottom */
928
@property (nonatomic, strong) UIImage *footerImage;
1029

1130
@end

Src/CLTableWithFooterViewController.m

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1-
//
2-
// CLTableWithFooterViewController.m
3-
//
4-
// Copyright (c) 2013 Chris Ledet
5-
//
1+
/*
2+
CLTableWithFooterViewController.m
3+
4+
Copyright (c) 2013 Chris Ledet
5+
Licensed under the MIT license <http://opensource.org/licenses/MIT>
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
10+
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or substantial portions
13+
of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
16+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
18+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19+
IN THE SOFTWARE.
20+
*/
621

722
#import "CLTableWithFooterViewController.h"
823

@@ -14,15 +29,29 @@ @interface CLTableWithFooterViewController()
1429

1530
@implementation CLTableWithFooterViewController
1631

32+
#pragma mark Layout
33+
1734
- (void)viewDidLoad
1835
{
1936
[super viewDidLoad];
2037

38+
if (!self.tableView) {
39+
[self setUpTableView];
40+
}
41+
2142
self.footerImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
2243
[self.view addSubview:self.footerImageView];
2344
}
2445

25-
#pragma mark - Properties
46+
- (void)setUpTableView
47+
{
48+
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
49+
self.tableView.delegate = self;
50+
self.tableView.dataSource = self;
51+
[self.view addSubview:self.tableView];
52+
}
53+
54+
#pragma mark Properties
2655

2756
- (void)setFooterImage:(UIImage *)footerImage
2857
{
@@ -34,7 +63,7 @@ - (void)setFooterImage:(UIImage *)footerImage
3463
}
3564
}
3665

37-
#pragma mark - UIScrollViewDelegate Methods
66+
#pragma mark UIScrollView Delegate
3867

3968
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
4069
{

0 commit comments

Comments
 (0)