0

I have a VC where I created a UITableView and added it to the main view. The table has his delegate and datasource added to the VC:

choicesTableView.dataSource = self
choicesTableView.delegate = self

I can see the table correctly and everything runs smooth.

In cellForRowAtIndexPath I've created a new UITextView and added to cell:

let myTextView = UITextView(frame: CGRectMake(0, 0, myVar.sW, 100))

(myVar.sW is a referenced value token from the screen width)

I added the UITextView to the cell:

cell.addSubview(myTextView)

Again, I see all as expected.

The Dark Side Of The Moon of this situation is that now I cannot get the didSelectRowAtIndexPath event since the UITextView is covering the cell's view. If I comment the addSubview method, the didSelectRowAtIndexPath is correctly fired.

Is there any way to let the UITextView pass the user interaction to the cell without creating a custom cell view from scratch?

(for your information, in this phase I'm not using the Interface Builder)

Thank you.

Wain
  • 118,658
  • 15
  • 128
  • 151
RikiRiocma
  • 746
  • 12
  • 28
  • Is the text view editable? Why aren't you using a label? – Wain Mar 20 '16 at 21:18
  • I'm using UITextView not for editing matters, only for cosmetic needs. The UITextView has the useful justifying method and other interesting things... :) – RikiRiocma Mar 20 '16 at 21:23

1 Answers1

0

The solution was pretty simple. I resolved my problem by adding this line:

myTextView.userInteractionEnabled = false

So the touch can pass through the UITextView's layer and reach the cell layer.

This thread has helped me.

Community
  • 1
  • 1
RikiRiocma
  • 746
  • 12
  • 28