凝った事をしようと思うと、自分でゴリゴリとCellをデザインする必要が出てくる。
だが、まずはSDKで提供されている機能の中でどこまでできるか試してみる。
用意したコードは下記、Cellリサイクル方法が、これでいいのかはいささか不安だが、
そこは今回の検証範囲ではないので黙殺。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = nil;
switch ( indexPath.row ) {
case 0:
cell = [tableView dequeueReusableCellWithIdentifier:@"Goal0"];
if ( cell == nil ) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Goal0"];
}
cell.textLabel.text = @"StyleDefault";
break;
case 1:
cell = [tableView dequeueReusableCellWithIdentifier:@"Goal1"];
if ( cell == nil ) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Goal1"];
}
cell.textLabel.text = @"StyleSubtitle";
break;
case 2:
cell = [tableView dequeueReusableCellWithIdentifier:@"Goal2"];
if ( cell == nil ) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"Goal2"];
}
cell.textLabel.text = @"StyleValue1";
break;
case 3:
cell = [tableView dequeueReusableCellWithIdentifier:@"Goal0"];
if ( cell == nil ) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"Goal3"];
}
cell.textLabel.text = @"StyleValue2";
break;
default:
break;
}
cell.detailTextLabel.text = @"detailTextLabel";
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.imageView.image = [UIImage imageNamed:@"hoge.png"];
return cell;
}
上記のコードは、Section:1 Row:4のUITableViewを想定したコード。で、出てきたテーブルはこういうものである。

0 件のコメント:
コメントを投稿