カスタムセルの作り方

UITableview用のcellはカスタマイズができる。

3列のテーブル作成

#import "ViewController.h"
#import "TACell.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    [_myTableView registerNib:[UINib nibWithNibName:NSStringFromClass([TACell class]) bundle:nil] forCellReuseIdentifier:@"cell"];
    
}

// テーブル関連の処理

//テーブル:ヘッダー
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section{
    return @"データ1    データ2    データ3";
}

//テーブル:セクション数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
//テーブル:行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:
    (NSInteger)section {
    return 10;
}

//テーブル:データ生成
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
    (NSIndexPath *)indexPath{
   
    TACell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.titleLabel.text = [NSString stringWithFormat:@"%@ %i", @"row", indexPath.row];
    return cell;
}