我正在使用“动态原型”UITableview
为其生成表格单元格,如下所示
-(UITableViewCell*)populateFeatureCell:(UITableView*)tableView row:(NSUInteger)row {
NSString *CellIdentifier = @"FeatureCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
SKProduct *product = [STLNavigatorIAPHelper productAtIndex:row];
if (product != nil) {
cell.textLabel.text = [product localizedTitle];
UIButton *buyButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buyButton.frame = CGRectMake(0, 0, 72, 37);
[buyButton setTitle:NSLocalizedString(@"BUY", nil) forState:UIControlStateNormal];
buyButton.tag = row;
[buyButton addTarget:self action:@selector(buyButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryView = buyButton;
}
[cell setUserInteractionEnabled:YES];
return cell;
}
我可以看到表格中的单元格,但该单元格不响应任何事件。请注意,该函数buyButtonTapped
也已定义。