无法在Uitable View(ios7)上禁用多点触控

时间:2013-09-16 10:25:48

标签: iphone ios objective-c uitableview ios7

我有一个问题,我使用UITableView的自定义单元格,当我在我的tableview上点击多个手指(2个或更多手指)时,我的labels出现了很多问题}每个单元格(显示信息)丢失的文本(它是空的)。所以我尝试在我的桌子上禁用多点触控,但这并不影响。我尝试将tableView.allowsMultipleSelection = NO;tableView.multipleTouchEnabled = NO;添加到cellForRowAtIndexPath or didSelectRowAtIndexPath。但没什么用。请帮我找出解决方案。

谢谢! 这是我的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    int row = indexPath.row;

@synchronized (self) {
    if (row == [voicemailItems count]) {
        // User selected the blank rows
        [tableView deselectRowAtIndexPath:indexPath animated:YES];

        // Blank out the play button on previous selected row
        [self deselect];

        return;
    }
}

if (selectedRowIndexPath != nil) {
    if (row == selectedRowIndexPath.row) {
        // Selecting the same row twice will play the voicemail
        if (streaming == NO) {
            if (calling == NO) {
                // Play the voicemail
                [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(playVoicemailAction:) userInfo:indexPath repeats:NO];
            }

            return;
        }
        else {
            // Streaming VM
            if ([self isCallInProgress] == YES) {
                [ScreenUtils errorAllert:@"Cannot play voicemail while call is in progress." type:kUINotice delegate:self];
            }
            else {
                if (![self isVoicemailNotification:selectedRowIndexPath.row]) {
                    // Stream the voicemail
                    [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(playVoicemailAction:) userInfo:indexPath repeats:NO];
                }
            }
        }
    }
    else {
        // Selecting a different row
        [self shutdownPlayer];
        [self cancel];

        // Blank out the play button on previous selected row
        [self deselect];
    }
}

selectedRowIndexPath = indexPath;

// Enable Call Back button 
// Don't enable if private, etc.
btnCallBack.enabled = ([self canCallBack:row] &&
                       !calling &&
                       ([self isCallInProgress] == NO) &&
                       ![self isVoicemailNotification:selectedRowIndexPath.row]);

// Enable and Delete button
btnDelete.enabled = YES;

// Select the cell
VoicemailCell * cell = (VoicemailCell*)[tblView cellForRowAtIndexPath:indexPath];
[cell select:YES playing:[self isPlaying] stream:streaming];
[tblView setNeedsDisplay];

//[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

3 个答案:

答案 0 :(得分:3)

试试这个,它对我有帮助!

cell.contentView.exclusiveTouch = YES;
cell.exclusiveTouch = YES;

答案 1 :(得分:1)

@try this

[cell setExclusiveTouch:YES]

答案 2 :(得分:1)

经过多次尝试,我发现我需要在didSelectRowAtIndexPath末尾添加以下代码:

[tableView deselectRowAtIndexPath:indexPath animated:YES];