我在uitableviewcell中有一个UITextView,我专门使用它来允许复制/粘贴内容。但是,单击textView不会转发到tableViewCell。

有没有办法解决?

最佳答案

您可以执行以下操作:

- (void)textTapped:(UITapGestureRecognizer *)recognizer
{
    // Get the text view from gesture recognizer or some delegate method
    UITextView *textView = (UITextView *)recognizer.view;

    UIView *cellToBeSelected = textView.superview;

    // Try to get the correct cell view according to received view hierarchical.
    while (![cellToBeSelected isKindOfClass:[UITableViewCell class]])
    {
        cellToBeSelected = [cellToBeSelected superview];
    }

    // Select the cell
    if (cellToBeSelected)
    {
        [self.tableView selectRowAtIndexPath:[self.tableView indexPathForCell:(UITableViewCell *)cellToBeSelected]
                                    animated:YES
                              scrollPosition:UITableViewScrollPositionNone];
    }
}

关于ios - 将水龙头从UITextView转发到UITableViewCell,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23706327/

10-13 04:05