あなたが作成したカスタムセルのラベルとボタンをフィールドにすると思います。カスタムセルでもアクションハンドラを作成すると、ラベルに簡単にアクセスできます。あなたがInterface Builderのを使用してカスタムセルを実装することができます
CustomCell.h
UIButton *button;
UILabel *label;
-(IBAction) updateLabel:(id) sender;
CustomCell.m
更新
//[button addAction:@selector(updateLabel) target:self];
-(IBAction) updateLabel:(id) sender{
[self.label setText:@" text"];
}
: それはそのようなものになるだろう。 Interface Builderからボタンにアクションを接続することもできます。アクションプロトタイプをヘッダファイルに移動する必要があります。そのファイルの所有者をViewTableControllerに設定して、そのセルをロードします。 は、その後、あなたがそのようにカスタムセルを読み込むことができTableViewController上とデリゲートメソッドにカスタムセルのための出口を作る:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)table_view cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cell_identifier = @"Cell";
CustomCell *cell;
cell=(CustomCell*)[table_view dequeueReusableCellWithIdentifier:cell_identifier];
if (cell==nil) {
self.customCell=nil;
[[NSBundle mainBundle] loadNibNamed:@"custom_cell" owner:self options:nil];
cell=self.customCell;
}
}
何CustomCellクラスがありませんので、私はプログラム的にUIButtonとUILabelをプログラムし...と、別のがあります方法? – SuperString
私はこのようにしてみましたが、CustomCellはUITableViewのサブビューだったので難しかったので、複雑でした。 – SuperString
Sarah - Appleの現在のスタイルに合わせて、ラベルをカスタムセルのプロパティにするだけです。また、プレースホルダオーナオブジェクトを必要とせずにUINibを使用して直接セルをロードすることもできます。 – nielsbot