Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not clickable in table view cell :( #221

Closed
alkincakiralar1996 opened this issue Nov 18, 2017 · 13 comments
Closed

Not clickable in table view cell :( #221

alkincakiralar1996 opened this issue Nov 18, 2017 · 13 comments

Comments

@alkincakiralar1996
Copy link

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "commonCommentCell", for: indexPath) as! CommonCommentTableViewCell
        cell.getData(userPhotoUrl: self.commentList[indexPath.section].userThumbnailUrl!, userName: self.commentList[indexPath.section].userName!, message: self.commentList[indexPath.section].content!, date: self.commentList[indexPath.section].crtm!)
        cell.contentView.backgroundColor = UIColor.white
        cell.layer.cornerRadius = 5.0
        cell.layoutMargins.top = 15
        /*cell.optionsButton.accessibilityHint = String(describing: self.commentList[indexPath.section].id!)
        cell.optionsButton.accessibilityLabel = String(describing: self.commentList[indexPath.section].isOwner!)
        cell.optionsButton.accessibilityValue = "\(indexPath.section)"
        cell.optionsButton.isUserInteractionEnabled = true
        let optionButtonTapGesture : UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(openOptions(_:)))
        cell.optionsButton.addGestureRecognizer(optionButtonTapGesture)
        */
        //cell.selectionStyle = UITableViewCellSelectionStyle.none
        
        cell.messageLabel.enabledTypes = [.mention, .hashtag]
        cell.messageLabel.hashtagColor = UIColor(r: 78, g: 194, b: 205)
        cell.messageLabel.mentionColor = UIColor(r: 78, g: 194, b: 205)
        
        cell.messageLabel.handleMentionTap { (str) in
            print("NOT WORKING")
        }
        
        cell.messageLabel.handleURLTap { (str) in
            print("NOT WORKING")
        }
        
        return cell
    }

its not working do you know why it is happening ?

@jeffcaljr
Copy link

Having the same issue. Were you able to resolve this?

@maziyarpanahi
Copy link
Collaborator

I have mine in UITableViewCell and CollectionViewCell and I can tell you it is very much selectable. Can you please follow the basic example in a new UITableView see if it works? Also, the version of the ActiveLabel and your Swift may help as well.

@Mahan3340
Copy link

Mahan3340 commented Jun 11, 2018

@jeffcaljr @alkincakiralar1996 @maziyarpanahi did you find any solution ? this happens for me too , specially when tableview is registered to show context menu on longPress

@maziyarpanahi
Copy link
Collaborator

@jeffcaljr @alkincakiralar1996 @Mahan3340
OK, I think I didn't get the question correctly. Is the TableViewCell not clickable or the Hashtags/URL/UserName are not clickable inside the TableViewCell?

@jeffcaljr
Copy link

jeffcaljr commented Jun 18, 2018

@Mahan3340 @alkincakiralar1996 @maziyarpanahi
No resolution thus far.

The TableViewCell itself is clickable; the tags/urls/usernames don’t respond to tap gestures. Long-pressing the links for almost exactly 3 seconds triggers their actions though.

@Mahan3340
Copy link

@maziyarpanahi @jeffcaljr I had a gesture recognizer for dismissing keyboard on tap I managed to do it in another way so the click is fine for me now (doesn't take long time to be clicked , just like normal) and doesn't conflict with context menu long press , but Lagging still exists for non English text as I opened an issues for it .

@maziyarpanahi
Copy link
Collaborator

@jeffcaljr we do have issues open when the Cell itself is not selectable, but I don't think the tags/mentions/URLs not be clickable or taking long for action is related to UITableView.
I do have UITableView and UICollectionView which have ActiveLabel without any issue for selecting hashtags or URLs.
Is there any customize gesture in the cell? Is it possible to just have a simple UITableView and check this separately to be sure nothing else is interfering?

@maziyarpanahi
Copy link
Collaborator

@Mahan3340 I follow up in your issue for other users in the future.

@pawanline
Copy link

@Mahan3340 how did you solve the issue? Can you please help me?

@Mahan3340
Copy link

Mahan3340 commented Aug 19, 2018

@pawanline I'm not currently using this Lib but back then as I said above , there was an gesture recognizer that was catching all the touches to dismiss Keyboard when user was tapping around , by removing it or modifying it so that it doesn't consume the touch , the click was working again . you might have something like that in your table , test it with a simple table with cells containing just labels and see if it works for you or not .

@pawanline
Copy link

@Mahan3340 thank man finally I solved my issue.I have done the same mistake as you.

@maziyarpanahi
Copy link
Collaborator

I am happy this issue has been resolved. Thanks @Mahan3340 for instruction and thanks @pawanline for confirming the fix.

@Patrick-Remy
Copy link

Patrick-Remy commented May 26, 2021

In my case the solution was to add this to the custom cell class, so that the touch events are propagated down to the label:

// MARK: - Pass touches events to ActiveLabel, so that tap handlers work

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    self.contentLabel.touchesBegan(touches, with: event)
    super.touchesBegan(touches, with: event)
}

override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
    self.contentLabel.touchesMoved(touches, with: event)
    super.touchesMoved(touches, with: event)
}

override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
    self.contentLabel.touchesEnded(touches, with: event)
    super.touchesEnded(touches, with: event)
}

override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
    self.contentLabel.touchesCancelled(touches, with: event)
    super.touchesCancelled(touches, with: event)
}

and use a custom form, to prevent endless delegate callings for those methods: https://github.com/Patrick-Remy/ActiveLabel.swift/tree/bugfix/endless-touches-events

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants