[英]trailingSwipeActionsConfigurationForRowAt not being called on iPhone simulator in Xcode - works on iPad simulator
Recently updated Xcode to 13.4.1.最近将 Xcode 更新到 13.4.1。
When I compile to any iPhone simulator, swiping a tableViewCell does not trigger trailingSwipeActionsConfigurationForRowAt.当我编译到任何 iPhone 模拟器时,滑动 tableViewCell 不会触发 trailingSwipeActionsConfigurationForRowAt。 Works fine on iPad simulator and on a real iPhone.在 iPad 模拟器和真正的 iPhone 上运行良好。
func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
} }
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// isn't getting this far on iPhone simulator!
let contextItem1 = UIContextualAction(style: .destructive, title: "Edit") { (contextualAction, view, completionHandler) in
self.edit(at: indexPath.adjustRowIndex())
completionHandler(true)
}
contextItem1.backgroundColor = UIColor.HIIT.green
let contextItem2 = UIContextualAction(style: .destructive, title: "Delete") { (contextualAction, view, completionHandler) in
let row = self.data[indexPath.adjustRowIndex().row]
self.alert(data: AlertDataObjects.delete(name: row.name), cancelCompletion: nil) {
self.deleteRow(at: indexPath.adjustRowIndex())
completionHandler(true)
}
}
contextItem2.backgroundColor = UIColor.red
let swipeActions = UISwipeActionsConfiguration(actions: [contextItem1, contextItem2])
swipeActions.performsFirstActionWithFullSwipe = true
return swipeActions
}
} }
This seemed to be happening because I was running Xcode in Rosetta mode (on an M1 MacBook).这似乎正在发生,因为我在 Rosetta 模式下(在 M1 MacBook 上)运行 Xcode。
Finder > Applications > Control + Click Xcode > Get Info - Uncheck Open in Rosetta Mode checkbox. Finder > Applications > Control + 单击 Xcode > Get Info - 取消选中 Open in Rosetta Mode 复选框。
Rosetta Mode off: delegate behaviour as expected, trailingSwipeActionsConfigurationForRowAt method called and simulator working as expected Rosetta Mode on: trailingSwipeActionsConfigurationForRowAt method called once on very first run of app / cell swipe, and after that, method not called at all. Rosetta 模式关闭:按预期委托行为,调用 trailingSwipeActionsConfigurationForRowAt 方法,模拟器按预期工作 Rosetta 模式打开:在第一次运行应用程序/单元格滑动时调用一次 trailingSwipeActionsConfigurationForRowAt 方法,之后,根本不调用方法。 (canEditRowAt is called normally) (canEditRowAt 正常调用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.