UITableViewCell遇到了麻烦。我试图获取选定的UITableViewCell的数据。最初,它运行良好,但是在UITapGestureRecognizer之后,它带来了麻烦。我使用的表格已分配给一个子视图,即使在第一次单击时也没有几个按钮不起作用。添加UITapGestureRecognizer之后,我正面临着这个麻烦。

tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self
                                                            action:@selector(didTapAnywhere:)];
    [tapRecognizer setNumberOfTapsRequired:1];
    [tapRecognizer setNumberOfTouchesRequired:1];
    [self.view addGestureRecognizer:tapRecognizer];
    [self.scrolling addGestureRecognizer:tapRecognizer];
    [self.notesView addGestureRecognizer:tapRecognizer];

-(void)didTapAnywhere: (UITapGestureRecognizer*) recognizer {

    [ageview removeFromSuperview];
    [contiView removeFromSuperview];
    [CountryTableview removeFromSuperview];
    [notesView endEditing:YES];
    [self.view endEditing:YES];
}

最佳答案

您的Tap Guesture正在取消对您的单元格和Button的触摸,请确保您为其分配了Tap Tapture的视图不与按钮重叠,否则将导致取消触摸事件

关于ios - UITableViewCell只接受longpress,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24988996/

10-10 10:05