Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 0f533a3

Browse files
Huddiernystrom
authored andcommitted
Switched from long press to tap recognizer for menu controllers (#2271)
1 parent 84a5872 commit 0f533a3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Classes/Views/MarkdownStyledTextView.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ class MarkdownStyledTextView: StyledTextView, StyledTextViewDelegate {
3838
// MARK: StyledTextViewDelegate
3939

4040
func didTap(view: StyledTextView, attributes: [NSAttributedStringKey : Any], point: CGPoint) {
41+
if let details = attributes[MarkdownAttribute.details] as? String {
42+
showDetailsInMenu(details: details, point: point)
43+
}
4144
guard let detected = DetectMarkdownAttribute(attributes: attributes) else { return }
4245
tapDelegate?.didTap(cell: self, attribute: detected)
4346
}
4447

4548
func didLongPress(view: StyledTextView, attributes: [NSAttributedStringKey : Any], point: CGPoint) {
46-
if let details = attributes[MarkdownAttribute.details] as? String {
47-
showDetailsInMenu(details: details, point: point)
48-
}
4949
if let urlString = attributes[MarkdownAttribute.url] as? String, let url = URL(string: urlString) {
5050
show(url: url)
5151
}

Classes/Views/ShowMoreDetailsLabel.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ final class ShowMoreDetailsLabel: UILabel {
1717

1818
isUserInteractionEnabled = true
1919

20-
let longPress = UILongPressGestureRecognizer(
20+
let tap = UITapGestureRecognizer(
2121
target: self,
2222
action: #selector(ShowMoreDetailsLabel.showMenu(recognizer:))
2323
)
24-
addGestureRecognizer(longPress)
24+
addGestureRecognizer(tap)
2525
}
2626

2727
required init?(coder aDecoder: NSCoder) {
@@ -34,8 +34,8 @@ final class ShowMoreDetailsLabel: UILabel {
3434

3535
// MARK: Private API
3636

37-
@objc func showMenu(recognizer: UILongPressGestureRecognizer) {
38-
guard recognizer.state == .began,
37+
@objc func showMenu(recognizer: UITapGestureRecognizer) {
38+
guard recognizer.state == .recognized,
3939
!detailText.isEmpty else { return }
4040

4141
becomeFirstResponder()

0 commit comments

Comments
 (0)