SweepStakeTableViewCellのデリゲートを作成し、それにSweepViewControllerを割り当てることができます。
@protocol SweepStakeTableViewCellDelegate <NSObject>
- (void)sweepTableViewCell:(SweepStakeTableViewCell *)cell buttonSelected:(UIButton *)button;
@end
テーブルビューデリゲート方法でセルを作成する際SweepStakeTableViewCellデリゲート方法(この場合、自己に)ビューコントローラを割り当てます。ボタンは、テーブルビューのセル内で選択された場合SweepStakeTableViewCell
@interface SweepStakeTableViewCell : UITableViewCell
.
.
@property (nonatomic, assign) id<SweepStakeTableViewCellDelegate> delegate;
.
@end
@implementation SweepStakeTableViewCell
.
- (void)buttonTapped:(id)sender
{
if ([delegate respondsToSelector:@selector(sweepTableViewCell:buttonSelected:)])
{
[delegate sweepTableViewCell:self buttonSelected:sender];
}
}
.
@end
、それはデリゲートメソッドということができますセルと選択ボタンで、この場合のビューコントローラ呼ぶために
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[SweepStakeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell...
.
.
.
cell.delegate = self;
return cell;
}
値を取得します。