質問編集履歴
4
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,25 @@
|
|
1
1
|
[contextMenuConfigurationForRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/3295956-tableview) で`UITableView`長押し時にメニューを表示しているのですが、
|
2
2
|
[shouldHighlightRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/1614988-tableview)が呼ばれて`shouldHighlightRowAt`内部に書かれている処理が実行されてしまいます。
|
3
3
|
~~`shouldHighlightRowAt`と`contextMenuConfigurationForRowAt`が呼ばれるのが順不同っぽいのですが、~~
|
4
|
-
`contextMenu`表示時にshouldHighlightRowAt`内部で処理を分岐する方法はないでしょうか?
|
4
|
+
`contextMenu`表示時に`shouldHighlightRowAt`内部で処理を分岐する方法はないでしょうか?
|
5
|
+
|
6
|
+
きちんと長押しされれば、`contextMenuConfigurationForRowAt`→`shouldHighlightRowAt`の順番に呼ばれるので、フラグでごまかしていますが、管理が煩わしくなるので、余計なフラグなどを設定せずに実現できないでしょうか?
|
7
|
+
|
8
|
+
```swift
|
9
|
+
|
10
|
+
var inProcess = false
|
11
|
+
|
12
|
+
func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
|
13
|
+
if inProcess { return false }
|
14
|
+
// 略
|
15
|
+
}
|
16
|
+
|
17
|
+
func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
|
18
|
+
inProcess = true
|
19
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
20
|
+
self.inProcess = false
|
21
|
+
}
|
22
|
+
// 略
|
23
|
+
}
|
24
|
+
|
25
|
+
```
|
3
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
[contextMenuConfigurationForRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/3295956-tableview) で`UITableView`長押し時にメニューを表示しているのですが、
|
2
2
|
[shouldHighlightRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/1614988-tableview)が呼ばれて`shouldHighlightRowAt`内部に書かれている処理が実行されてしまいます。
|
3
|
-
`shouldHighlightRowAt`と`contextMenuConfigurationForRowAt`が呼ばれるのが順不同っぽいのですが、
|
3
|
+
~~`shouldHighlightRowAt`と`contextMenuConfigurationForRowAt`が呼ばれるのが順不同っぽいのですが、~~
|
4
4
|
`contextMenu`表示時にshouldHighlightRowAt`内部で処理を分岐する方法はないでしょうか?
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
[contextMenuConfigurationForRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/3295956-tableview) で`UITableView`長押し時にメニューを表示しているのですが、
|
2
2
|
[shouldHighlightRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/1614988-tableview)が呼ばれて`shouldHighlightRowAt`内部に書かれている処理が実行されてしまいます。
|
3
|
-
|
3
|
+
`shouldHighlightRowAt`と`contextMenuConfigurationForRowAt`が呼ばれるのが順不同っぽいのですが、
|
4
4
|
`contextMenu`表示時にshouldHighlightRowAt`内部で処理を分岐する方法はないでしょうか?
|
1
訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
[contextMenuConfigurationForRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/3295956-tableview) で`UITableView`長押し時にメニューを表示しているのですが、
|
2
2
|
[shouldHighlightRowAt](https://developer.apple.com/documentation/uikit/uitableviewdelegate/1614988-tableview)が呼ばれて`shouldHighlightRowAt`内部に書かれている処理が実行されてしまいます。
|
3
3
|
|
4
|
-
`表示時に
|
4
|
+
`contextMenu`表示時にshouldHighlightRowAt`内部で処理を分岐する方法はないでしょうか?
|