1 Jul 2017

Custom TableView cell registerNib Code...


Custom TableView cell registerNib Code...

#import "ViewController.h"
#import "TableViewCell.h" //Custom TableViewCell class

@interface ViewController ()
@end
static NSString* const cellIdentifier = @"TableViewCellid";
@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.TableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    
    self.TableView.estimatedRowHeight = 44.0;
    self.TableView.rowHeight = UITableViewAutomaticDimension;
    
    self.TableView.delegate = self;
    self.TableView.dataSource = self;
    
    UINib *nib= [UINib nibWithNibName:@"TableViewCell" bundle:nil];
    [self.TableView registerNib:nib forCellReuseIdentifier:cellIdentifier];

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 10;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    TableViewCell *cell = [self.TableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[TableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    


}


2 comments:

Recent Posts

Codable demo

Link: https://www.dropbox.com/s/kw7c1kgv1628bh7/codableDemo.zip?dl=0