mvm_core_ui/MVMCoreUI/BaseControllers/MFProgrammaticTableViewController.m
Pfeil, Scott Robert 98fa47aaae Migration
2019-01-10 14:23:14 -05:00

109 lines
3.3 KiB
Objective-C

//
// MFProgrammaticTableViewController.m
// myverizon
//
// Created by Scott Pfeil on 12/17/14.
// Copyright (c) 2014 Verizon Wireless. All rights reserved.
//
#import "MFProgrammaticTableViewController.h"
#import "NSLayoutConstraint+MVMCoreUIConvenience.h"
#import <MVMCore/NSDictionary+MFConvenience.h>
@import MVMAnimationFramework;
@interface MFProgrammaticTableViewController ()
@end
@implementation MFProgrammaticTableViewController
- (void)registerWithTable {}
#pragma mark - View Life Cycle
- (void)loadView {
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
view.backgroundColor = [UIColor whiteColor];
view.clipsToBounds = YES;
UITableView *tableView = [self createTableView];
[tableView setTranslatesAutoresizingMaskIntoConstraints:NO];
[view addSubview:tableView];
// Sets the constraints for the table view
NSDictionary *constraints = [NSLayoutConstraint constraintPinSubviewToSuperview:tableView];
self.topConstraint = [constraints objectForKey:ConstraintTop ofType:[NSLayoutConstraint class]];
self.bottomConstraint = [constraints objectForKey:ConstraintBot ofType:[NSLayoutConstraint class]];
self.scrollView = tableView;
self.tableView = tableView;
self.view = view;
}
- (void)viewDidLoad {
// Registers classes with the table
[self registerWithTable];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (nonnull UITableView *)createTableView {
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.backgroundColor = [UIColor clearColor];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
tableView.delegate = self;
tableView.dataSource = self;
if ([tableView respondsToSelector:@selector(setCellLayoutMarginsFollowReadableWidth:)]) {
tableView.cellLayoutMarginsFollowReadableWidth = NO;
}
return tableView;
}
- (void)setToHaveNoSectionHeadersFooters {
self.tableView.sectionHeaderHeight = CGFLOAT_MIN;
self.tableView.sectionFooterHeight = CGFLOAT_MIN;
}
#pragma mark - TableView Functions
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
NSInteger numberOfSections = 0;
// Fixes a funky issue where the table is being loaded before it should be.
if (CGRectGetWidth(self.tableView.bounds) > 1) {
numberOfSections = [self getNumberOfSections];
}
return numberOfSections;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * const cellIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
return cell;
}
-(void)setupIntroAnimations {
[self.introAnimationManager addAnimationWithAnimation:[MVMAnimations animateTableViewFadeInCellsWithTableView:self.tableView]];
}
@end