Skip to content

Commit

Permalink
Added optional UITableView property.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
chrisledet committed Sep 13, 2013
1 parent 4fe220e commit 60c197e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Example/Classes/CLViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

#import "CLTableWithFooterViewController.h"

@interface CLViewController : CLTableWithFooterViewController <UITableViewDataSource>
@interface CLViewController : CLTableWithFooterViewController

@end
12 changes: 5 additions & 7 deletions Example/Classes/CLViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ - (void)viewDidLoad

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

UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
tableView.delegate = self;
tableView.dataSource = self;
tableView.backgroundColor = [UIColor colorWithRed:237/255.0 green:97/255.0 blue:97/255.0 alpha:1.0];
tableView.separatorColor = [UIColor clearColor];

[self.view addSubview:tableView];
// Customize table view
self.tableView.backgroundColor = [UIColor colorWithRed:237/255.0 green:97/255.0 blue:97/255.0 alpha:1.0];
self.tableView.separatorColor = [UIColor clearColor];
}

#pragma mark UITableView DataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return MAX_CELL_COUNT + 1;
Expand Down
31 changes: 25 additions & 6 deletions Src/CLTableWithFooterViewController.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
//
// CLTableWithFooterViewController.h
//
// Copyright (c) 2013 Chris Ledet
//
/*
CLTableWithFooterViewController.h
@interface CLTableWithFooterViewController : UIViewController <UITableViewDelegate>
Copyright (c) 2013 Chris Ledet
Licensed under the MIT license <http://opensource.org/licenses/MIT>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
*/

@interface CLTableWithFooterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>

/* A handy UITableView already setup on load if you don't assign one yourself */
@property (nonatomic, strong) UITableView *tableView;

/* Required UIImage for the footer. It will remain move as you scroll until you reach the bottom */
@property (nonatomic, strong) UIImage *footerImage;

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

#import "CLTableWithFooterViewController.h"

Expand All @@ -14,15 +29,29 @@ @interface CLTableWithFooterViewController()

@implementation CLTableWithFooterViewController

#pragma mark Layout

- (void)viewDidLoad
{
[super viewDidLoad];

if (!self.tableView) {
[self setUpTableView];
}

self.footerImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
[self.view addSubview:self.footerImageView];
}

#pragma mark - Properties
- (void)setUpTableView
{
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.view addSubview:self.tableView];
}

#pragma mark Properties

- (void)setFooterImage:(UIImage *)footerImage
{
Expand All @@ -34,7 +63,7 @@ - (void)setFooterImage:(UIImage *)footerImage
}
}

#pragma mark - UIScrollViewDelegate Methods
#pragma mark UIScrollView Delegate

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
Expand Down

0 comments on commit 60c197e

Please sign in to comment.