2012-10-18 45 views
1

我使用的“动态原型”的UITableView针对我生成表格单元如下的UIButton嵌入cell.accessoryVIew没有响应

 
-(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也已被定义。

回答

0

索引路径中的表格行正在获得第一次打击。

您可以在那里处理或传入按钮。