// // MFProgrammaticTableViewController.m // myverizon // // Created by Scott Pfeil on 12/17/14. // Copyright (c) 2014 Verizon Wireless. All rights reserved. // #import "MFProgrammaticTableViewController.h" #import "NSLayoutConstraint+MFConvenience.h" @import MVMCore.NSDictionary_MFConvenience; @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; tableView.insetsContentViewsToSafeArea = NO; 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