Skip to content

Instantly share code, notes, and snippets.

@rajivnarayana
Created January 23, 2013 14:02
Show Gist options
  • Save rajivnarayana/4605950 to your computer and use it in GitHub Desktop.
Save rajivnarayana/4605950 to your computer and use it in GitHub Desktop.
Custom TableViewController which has a UIView as a parent.
#import <UIKit/UIKit.h>
@interface MyTableViewController : UITableViewController {
}
@end
#import "MyTableViewController.h"
@interface MyTableViewController () {
UIView *view;
UITableView *tableView;
}
@end
@implementation MyViewController
- (id) init {
self = [super init];
if (self) {
}
return self;
}
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void) loadView {
view = [[UIView alloc] initWithFrame:CGRectZero];
view.backgroundColor = [UIColor cyanColor];
// self.view = view;
[self tableView];
[self viewDidLoad];
}
- (UIView *) view {
[super loadView];
if (view == nil) {
[self loadView];
}
return view;
}
- (UITableView *) tableView {
if (tableView == nil) {
tableView = [[UITableView alloc] initWithFrame:view.bounds style:UITableViewStylePlain];
[self.view addSubview:tableView];
[tableView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
}
return tableView;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *loadingView = [[UIView alloc] initWithFrame:self.view.bounds];
loadingView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:loadingView];
[loadingView setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.4f]];
// self.title = @"Demo";
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
#warning Incomplete method implementation.
// Return the number of rows in the section.
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment