我有一個問題...如何捕獲在自定義tableViewCell中更改的開關事件?
我有自定義TableViewCell類:
// Class for Custom Table View Cell.
@interface CustomTableViewCell : UITableViewCell {
// Title of the cell.
UILabel* cellTitle;
// Switch of the cell.
UISwitch* cellSwitch;
}
你怎麼可以在我的自定義的UITableViewCell看到我有標籤和開關控制器。
- (id)initWithStyle: (UITableViewCellStyle)style reuseIdentifier: (NSString *)reuseIdentifier tableType:(TableTypeEnumeration)tabletypeEnum {
// Get Self.
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Create and initialize Title of Custom Cell.
cellTitle = [[UILabel alloc] initWithFrame:CGRectMake(10, (44 - TAGS_TITLE_SIZE)/2, 260, 21)];
cellTitle.backgroundColor = [UIColor clearColor];
cellTitle.opaque = NO;
cellTitle.textColor = [UIColor blackColor];
cellTitle.highlightedTextColor = [UIColor whiteColor];
cellTitle.font = [UIFont boldSystemFontOfSize:TAGS_TITLE_SIZE];
cellTitle.textAlignment = UITextAlignmentLeft;
// Create and Initialize Switch of Custom Cell.
cellSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(185, 10, 10, 10)];
[self.contentView addSubview:cellTitle];
[self.contentView addSubview:cellSwitch];
[cellTitle release];
[cellSwitch release];
}
return self;
}
現在,當我用我的自定義單元格中的TableView我想趕上事件,當用戶改變開關的狀態。我怎樣才能做到這一點 ?
某些警告顯示!!! Whot我必須杜? – 2011-03-24 07:31:24