1

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関数も定義されていることに注意してください。

4

1 に答える 1