mirror of
https://github.com/gimenete/iOS-boilerplate.git
synced 2026-04-24 03:00:01 -04:00
142 lines
3.8 KiB
Objective-C
142 lines
3.8 KiB
Objective-C
//
|
|
// ListViewController.m
|
|
// IOSBoilerplate
|
|
//
|
|
// Copyright (c) 2011 Alberto Gimeno Brieba
|
|
//
|
|
// 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 "ListViewController.h"
|
|
|
|
@implementation ListViewController
|
|
|
|
@synthesize table;
|
|
|
|
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
|
|
{
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
if (self) {
|
|
// Custom initialization
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning
|
|
{
|
|
// Releases the view if it doesn't have a superview.
|
|
[super didReceiveMemoryWarning];
|
|
|
|
// Release any cached data, images, etc that aren't in use.
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
if (_refreshHeaderView == nil) {
|
|
|
|
EGORefreshTableHeaderView *view = [[EGORefreshTableHeaderView alloc] initWithFrame:CGRectMake(0.0f, 0.0f - self.table.bounds.size.height, self.view.frame.size.width, self.table.bounds.size.height)];
|
|
view.delegate = self;
|
|
[self.table addSubview:view];
|
|
_refreshHeaderView = view;
|
|
[view release];
|
|
|
|
}
|
|
|
|
// update the last update date
|
|
[_refreshHeaderView refreshLastUpdatedDate];
|
|
}
|
|
|
|
#pragma mark -
|
|
#pragma mark Data Source Loading / Reloading Methods
|
|
|
|
- (void)reloadTableViewDataSource {
|
|
_reloading = YES;
|
|
// TO be implemented
|
|
}
|
|
|
|
- (void)doneLoadingTableViewData {
|
|
// model should call this when its done loading
|
|
_reloading = NO;
|
|
[_refreshHeaderView egoRefreshScrollViewDataSourceDidFinishedLoading:self.table];
|
|
}
|
|
|
|
|
|
#pragma mark -
|
|
#pragma mark UIScrollViewDelegate Methods
|
|
|
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
|
|
[_refreshHeaderView egoRefreshScrollViewDidScroll:scrollView];
|
|
}
|
|
|
|
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
|
|
[_refreshHeaderView egoRefreshScrollViewDidEndDragging:scrollView];
|
|
}
|
|
|
|
|
|
#pragma mark -
|
|
#pragma mark EGORefreshTableHeaderDelegate Methods
|
|
|
|
- (void)egoRefreshTableHeaderDidTriggerRefresh:(EGORefreshTableHeaderView*)view{
|
|
[self reloadTableViewDataSource];
|
|
}
|
|
|
|
- (BOOL)egoRefreshTableHeaderDataSourceIsLoading:(EGORefreshTableHeaderView*)view {
|
|
return _reloading; // should return if data source model is reloading
|
|
}
|
|
|
|
- (NSDate*)egoRefreshTableHeaderDataSourceLastUpdated:(EGORefreshTableHeaderView*)view {
|
|
return [NSDate date]; // should return date data source was last changed
|
|
}
|
|
|
|
|
|
#pragma mark - View lifecycle
|
|
|
|
/*
|
|
// Implement loadView to create a view hierarchy programmatically, without using a nib.
|
|
- (void)loadView
|
|
{
|
|
}
|
|
*/
|
|
|
|
/*
|
|
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
|
- (void)viewDidLoad
|
|
{
|
|
[super viewDidLoad];
|
|
}
|
|
*/
|
|
|
|
- (void)viewDidUnload
|
|
{
|
|
[super viewDidUnload];
|
|
_refreshHeaderView = nil;
|
|
}
|
|
|
|
- (void)dealloc {
|
|
[table release];
|
|
_refreshHeaderView = nil;
|
|
[super dealloc];
|
|
}
|
|
|
|
@end
|