badoo / badoo/Chatto

Custom long press pop menu

Open
#141 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4.6k
Forks
588
PR merge metrics
No merged PRs in 30d

Description

How to custom long press pop menu?

This is my code:

let menuItem: UIMenuItem = UIMenuItem(title: "speech", action: #selector(AudioMessageCollectionViewCell.speech(_:)))
UIMenuController.sharedMenuController().menuItems = [menuItem]
UIMenuController.sharedMenuController().update()

public class AudioMessageCollectionViewCell: BaseMessageCollectionViewCell {

```
override public func canBecomeFirstResponder() -> Bool {
return true
}

public override func canPerformAction(action: Selector, withSender sender: AnyObject?) -> Bool {
if action == #selector(AudioMessageCollectionViewCell.speech(_:)) {
return true
} else {
return false
}
}

func speech(sender: AnyObject) {
// your custom action
}
```

}

Contributor guide

Open the contributing guide

Research direction

Start at the UIMenuController setup and AudioMessageCollectionViewCell methods shown in the issue, then trace how the framework handles long-press responders and menu actions. Confirm the intended custom-menu behavior with the issue author before changing code; done should mean the requested menu appears for the relevant cell and its action is invoked.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.