diff --git a/Example/Classes/CLViewController.h b/Example/Classes/CLViewController.h index 358994a..8ad22ff 100644 --- a/Example/Classes/CLViewController.h +++ b/Example/Classes/CLViewController.h @@ -8,6 +8,6 @@ #import "CLTableWithFooterViewController.h" -@interface CLViewController : CLTableWithFooterViewController +@interface CLViewController : CLTableWithFooterViewController @end diff --git a/Example/Classes/CLViewController.m b/Example/Classes/CLViewController.m index f2f994f..dc73e03 100644 --- a/Example/Classes/CLViewController.m +++ b/Example/Classes/CLViewController.m @@ -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; diff --git a/Src/CLTableWithFooterViewController.h b/Src/CLTableWithFooterViewController.h index 54bbc80..d4cd83f 100644 --- a/Src/CLTableWithFooterViewController.h +++ b/Src/CLTableWithFooterViewController.h @@ -1,11 +1,30 @@ -// -// CLTableWithFooterViewController.h -// -// Copyright (c) 2013 Chris Ledet -// +/* + CLTableWithFooterViewController.h -@interface CLTableWithFooterViewController : UIViewController + Copyright (c) 2013 Chris Ledet + Licensed under the MIT license + 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 + +/* 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 diff --git a/Src/CLTableWithFooterViewController.m b/Src/CLTableWithFooterViewController.m index ce82948..55aee65 100644 --- a/Src/CLTableWithFooterViewController.m +++ b/Src/CLTableWithFooterViewController.m @@ -1,8 +1,23 @@ -// -// CLTableWithFooterViewController.m -// -// Copyright (c) 2013 Chris Ledet -// +/* + CLTableWithFooterViewController.m + + Copyright (c) 2013 Chris Ledet + Licensed under the MIT license + + 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" @@ -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 { @@ -34,7 +63,7 @@ - (void)setFooterImage:(UIImage *)footerImage } } -#pragma mark - UIScrollViewDelegate Methods +#pragma mark UIScrollView Delegate - (void)scrollViewDidScroll:(UIScrollView *)scrollView {