如何为 CollectionView iOS Swift 禁用上下文菜单的长按动画?
How to disable long-press animation of context menu for CollectionView iOS Swift?
我的 ViewController 为我创建的所有 UICollectionView 创建了 contextMenu,但对于最后一个 UICollectionView,我不想显示菜单,对于 一切正常,但长按的 UICollectionview 动画没有被禁用。
如何关闭最后一个UICollectionView的长按动画?确实很简单,但是我无法删除默认大小写。
我的代码示例:
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
switch collectionView {
case favoriteCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
case allCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
default:
// This menu empty and doesn't show but the animation of long pressed not disabled how to fix this?
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil)
}
}
通过 return nil
而不是 return UIContextMenuConfiguration(identifier: nil, previewProvider: nil)
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
switch collectionView {
case favoriteCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
case allCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
default:
return nil //<-- HERE
}
}
我的 ViewController 为我创建的所有 UICollectionView 创建了 contextMenu,但对于最后一个 UICollectionView,我不想显示菜单,对于
如何关闭最后一个UICollectionView的长按动画?确实很简单,但是我无法删除默认大小写。
我的代码示例:
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
switch collectionView {
case favoriteCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
case allCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
default:
// This menu empty and doesn't show but the animation of long pressed not disabled how to fix this?
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil)
}
}
通过 return nil
而不是 return UIContextMenuConfiguration(identifier: nil, previewProvider: nil)
func collectionView(_ collectionView: UICollectionView, contextMenuConfigurationForItemAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
switch collectionView {
case favoriteCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
case allCollectionView:
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) {...}
default:
return nil //<-- HERE
}
}