tableView:cellForRowAtIndexPath:
INDEX>UIKit>UITableViewDataSource
テーブルに表示するセルを返します。
-(UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
解説
返り値
( UITableViewCell * )
引数
( UITableView * )tableView
( NSIndexPath * )indexPath
フレームワーク
UIKit
クラス
UITableViewDataSource
Instance Methods
使用可能
iPhone2.0
参照
例文
//セルを返す(表示する)
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil) {
// Create a new cell. CGRectZero allows the cell to determine the appropriate size.
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"MyIdentifier"] autorelease];
}
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 12.0, 320.0, 25.0)] autorelease];
label.tag = 0;
label.font = [UIFont systemFontOfSize:24.0];
label.textAlignment = UITextAlignmentRight;
label.textColor = [UIColor blueColor];
label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
label.text = @"あああいいいいいううううううう";
switch (indexPath.section) {
case 0: [cell.contentView addSubview:label]; break;
case 1: [cell.contentView addSubview:label]; break;
case 2: [cell.contentView addSubview:label]; break;
}
return cell;
}