【发布时间】:2020-07-16 22:01:40
【问题描述】:
我创建了一个简单的 ContextMenu
override func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil){ action in
let delete = UIAction(title: "Delete", image: UIImage(systemName: "trash.fill"), identifier: nil,discoverabilityTitle: nil, attributes: .destructive, handler: {action in
self.deleteItem(index: indexPath.item)
})
return UIMenu(title: "", image: nil, identifier: nil, children: [delete])
}
return configuration
}
它会在控制台中引发以下警告。
2020-07-16 22:58:16.227394+0200 RunPersonalRecord[8410:2186970] [LayoutConstraints] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
Try this:
(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints and fix it.
(Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
"<NSAutoresizingMaskLayoutConstraint:0x280eec230 h=--& v=--& UIInterfaceActionGroupView:0x1658ca700.height == 0 (active)>",
"<NSLayoutConstraint:0x280ed7e80 groupView.actionsSequence....height >= 44 (active, names: groupView.actionsSequence...:0x158340200 )>",
"<NSLayoutConstraint:0x280ed4a00 UIInterfaceActionGroupView:0x1658ca700.top == _UIContentConstraintsLayoutGuide:0x157d4dae0''.top (active)>",
"<NSLayoutConstraint:0x280ed4140 V:[_UIContentConstraintsLayoutGuide:0x157d4dae0'']-(0)-| (active, names: '|':UIInterfaceActionGroupView:0x1658ca700 )>",
"<NSLayoutConstraint:0x280ed6710 groupView.actionsSequence....top == _UIContentConstraintsLayoutGuide:0x157d4dae0''.top (active, names: groupView.actionsSequence...:0x158340200 )>",
"<NSLayoutConstraint:0x280ed6760 groupView.actionsSequence....bottom == _UIContentConstraintsLayoutGuide:0x157d4dae0''.bottom (active, names: groupView.actionsSequence...:0x158340200 )>") Will attempt to recover by breaking constraint <NSLayoutConstraint:0x280ed7e80 groupView.actionsSequence....height >= 44 (active, names: groupView.actionsSequence...:0x158340200 )>
这可能是苹果的错误还是有可能以某种方式修复?谢谢!
【问题讨论】:
-
您能否分享您将
UIMenu附加到主视图的代码部分? -
这段代码不太可能是您的问题。检查您的
groupView约束 -
我在 contextMenuConfigurationForItemAt 中创建了 ContextMenu
-
在 GitHub 上找到了 2 个具有相同功能的项目,并且都导致了我描述的问题。看起来像苹果虫。
标签: ios swift xcode uikit ios13