UILabel and UIImageView オブジェクトの属性(カラー、フォント、イメージ等)をセットできる。
標準でないスタイルを持たせる場合は、セル内容のビュー (contentView プロパティ) でサブビューを加えることができる。
UITableViewCell オブジェクトの生成
– (id)initWithStyle:(UITabelViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifierUITableViewCellStyleDefault テキストラベル(黒文字、左寄せ)付きの単純なセルスタイル。UITableViewCellStyleValue1 左に黒テキスト(左寄せ)ラベルがあり、右手に青テキスト(右寄せ)ラベルがあるセルスタイル。設定画面等に使われている。UITableViewCellStyleValue2 左に青テキスト(右寄せ)ラベルがあり、右手に黒テキスト(左寄せ)ラベルがあるセルスタイル。連絡先等に使われている。UITableViewCellStyleSubtitle 上部に渡り左寄せのラベルがあり、さらにその下に小さい左寄せのグレーテキストがあるセルスタイル
以下はOS2.0以前用– initWithFrame:reuseIdentifier:
セルをリユースする
reuseIdentifierproperty– prepareForReuse
セル内のテキストを管理する
UILabel *textLabelproperty- ex. cell.textLabel.text = [listData objectAtIndex:row];
- cell.textLabel.font = [UIFont boldSystemFontOfSize: 25];
UILabel *detailTextLabelproperty
以下はOS2.0以前用
NSString *textpropertyUIFont *fontpropertyUITextAlignment textAlignmentpropertyUIColor *textColorpropertyUIColor *selectedTextColorpropertyUILineBreakMode lineBreakModeproperty
セル内のイメージを管理する
UIImageView *imageViewproperty-
- ex. UIImage *image = [UIImage imageNamed:@"star.png"];
- UIImage *image2 = [UIImage imageNamed:@"satr2.png"]
- cell.imageView.image = image;
- cell.imageView.highlightedImage = Image2;
-
- 以下はOS2.0以前用
UIImage *imagepropertyUIImage *selectedImageproperty
セルオブジェクトのビューにアクセスする
UIView contentViewproperty- Cellオブジェクトの表示オブジェクトを返す(読み取り専用)。
CGRect nameLabelRect = CGRectMake(0, 5, 70, 15);
UILabel *nameLabel = [[UILabel alloc] initWithFrame:nameLabelRect];
nameLabel.textAlignment = UITextAlignmentRight;
nameLabel.text = @"Name:";
nameLabel.font = [UIFont boldSystemFontOfSize:12];
[cell.contentView addSubview: nameLabel];
[nameLabel release];
ex.2
CGRect nameValueRect = CGRectMake(80, 5, 200, 15);
UILabel *nameValue = [[UILabel alloc] initWithFrame: nameValueRect];
nameValue.tag = kNameValueTag;
[cell.contentView addSubview:nameValue];
[nameValue release];
.
.
NSUInteger row = [indexPath row];
NSDictionary *rowData = [self.computers objectAtIndex:row];
UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
name.text = [rowData objectForKey:@"Name"];
backgroundViewpropertyselectedBackgroundViewproperty
アクセサリビューを管理する
accessoryTypepropertyaccessoryViewpropertyeditingAccessoryTypepropertyeditingAccessoryViewpropertyhidesAccessoryWhenEditingproperty
セルの選択とハイライトを管理する
selectedpropertyselectionStyleproperty– setSelected:animated:highlightedproperty– setHighlighted:animated:
セルを編集する
editingproperty– setEditing:animated:editingStylepropertyshowingDeleteConfirmationpropertyshowsReorderControlproperty
状態遷移を変更する
コンテンツの字下げを管理する
indentationLevelpropertyindentationWidthpropertyshouldIndentWhileEditingproperty
ターゲットとアクションを管理する
These properties are deprecated as of iPhone OS 3.0. Instead, use the
tableView:commitEditingStyle:forRowAtIndexPath: method of theUITableViewDataSource protocol or the tableView:accessoryButtonTappedForRowWithIndexPath: method of the UITableViewDelegate protocol.targetpropertyeditActionpropertyaccessoryActionproperty

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