【问题标题】:UITextView in custom UITableViewCell not responding to didSelectRowAtIndexPath自定义 UITableViewCell 中的 UITextView 没有响应 didSelectRowAtIndexPath
【发布时间】:2011-05-19 22:11:40
【问题描述】:

我的自定义 UITableViewCell 中有一个 UITextView,问题是当我点击它时,它不会响应 didSelectRowAtIndexPath 甚至滑动事件。我怎样才能解决这个问题?此 UITextView 不可编辑。我在 UITextField 上使用它的原因是因为我希望能够轻松检测链接。

【问题讨论】:

    标签: iphone objective-c ipad uitableview uitextview


    【解决方案1】:

    我意识到这是一个老问题,但我最近遇到了同样的问题。在我的情况下,解决方法是简单地关闭 UITextView 的“启用用户交互”。

    【讨论】:

      【解决方案2】:

      您需要将触摸消息从 UITableView 转发到 UITextView

      UITextView inside UITableView

      【讨论】:

      • 那么你是说整个单元格必须是 UITextView?
      【解决方案3】:

      想到的第一个想法……

      在 cellForRow 中设置 textfield 标签为 indexpath.row

      实现- (void)textViewDidBeginEditing:(UITextView *)textView

      基于这个textView.tag,调用selectrow

          [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:textView.tag inSection:<#(NSUInteger)#>] 
      animated:<#(BOOL)#> scrollPosition:<#(UITableViewScrollPosition)#>]
      

      【讨论】:

        【解决方案4】:

        我不知道这是否是您要查找的内容但在我的情况下,我有一个带有 UIImage 和 UITextView 的自定义单元格,只有当我单击 UIImageView 时,我才得到 didSelectRowAtIndexPath 识别器。确保 UITextView 是用户交互无法解决问题

        【讨论】:

          【解决方案5】:

          检查您的 TableView Selection 属性是否设置为 NO

          错误: tableView.allowsSelection = false

          DidSelect 不会被调用 它一定要是: tableView.allowsSelection = true

          还有Check your Nib

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2016-05-23
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2016-03-15
            • 1970-01-01
            相关资源
            最近更新 更多