XIB中用作Custom UITableViewCell的自定义按钮不响应tap(ios7)

Jav*_*eux 16 objective-c uibutton uitableview ios ios7

所以我在这里将ios6应用程序升级到ios7,现在我无法在tableviewcells中的自定义按钮(或其他子视图)上接收点击或其他操作.

编辑:

我的代码:

这是我部署PlaceCell的地方

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellIdentifier = @"PlaceCell";

    PlaceCell *cell = [tableView dequeueReusableCellWithIdentifier: cellIdentifier];

    if (!cell) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"PlaceCell" owner:self options:nil];
        cell = [nib lastObject];
        cell.reuseIdentifier = cellIdentifier;
    }
    [cell configureCellWithPlace: [self.places objectAtIndex:indexPath.row]];
    cell.delegate = self;
    cell.userInteractionEnabled = YES;

    return cell;
}
Run Code Online (Sandbox Code Playgroud)

然后它是一个普通的自定义单元格,其按钮通过界面连接到某些操作.它与iOS6完美配合,但它与iOS7无关.

谢谢您的帮助.

Jav*_*eux 33

解决:

[cell.contentView setUserInteractionEnabled: NO];
Run Code Online (Sandbox Code Playgroud)

  • 它没有.那怎么解决呢?我的意思是你的按钮是contentView的一部分.在contentView中禁用userInteraction也会禁用底部的userInteraction. (4认同)