无法单击UITableCell中的标签

时间:2016-02-08 03:55:41

标签: ios uitableview

在我的表格单元格中,我有不同的控件,我面临的问题是我无法点击控件的单元格,在此代码中,我使用单击点击用户名标签,但是当我点击它时#s; s不要去UserNameTap:选择器。任何人都可以帮我解决这个问题

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *cellIdentifier = @"messagingCell";

PTSMessagingCell *cell =
[self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell == nil) {
    cell = [[PTSMessagingCell alloc]
            initMessagingCellWithReuseIdentifier:cellIdentifier];
    NSString *strUserID, *strUsername;

    strUserID = UserID[indexPath.row];
    strUsername = UserName[indexPath.row];

    if ([LoginUserName isEqualToString:strUsername]) {
        cell.rightUtilityButtons = [self rightButtons];
    } else {
        cell.rightUtilityButtons = [self rightReportButtons];
    }
}

cell.selectionStyle = UITableViewCellSelectionStyleNone;


NSString *strUserID, *strUsername;

strUserID = UserID[indexPath.row];
strUsername = UserName[indexPath.row];

if ([LoginUserName isEqualToString:strUsername]) {
    cell.rightUtilityButtons = [self rightButtons];
} else {
    cell.rightUtilityButtons = [self rightReportButtons];
}

cell.sent = NO;
[cell.messageLabel setText:Commments[indexPath.row]];
cell.messageLabel.userInteractionEnabled = YES;
[cell.userName setText:UserName[indexPath.row]];

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(UserNameTap:)];
singleTap.numberOfTapsRequired = 1;
singleTap.numberOfTouchesRequired = 1;
[cell.userName addGestureRecognizer:singleTap];
[cell.userName setUserInteractionEnabled:YES];

0 个答案:

没有答案