作为问题,我试图在 Collection View 中添加一个“索引标题”,以便快速导航我的 UIColletionView
的内容。
我读到过,从 iOS 10 开始,像 indexTitles(for:)
和 collectionView(_:indexPathForIndexTitle:at:)
这样的方法可以帮助我与 UITableViews 中一样。但我没有得到任何结果!你知道如何使用这些方法了吗?在此先感谢您的帮助。
最佳答案
如果您查看 UICollectionView.h
,indexTitlesForCollectionView
仅在 tvos 中可用:
/// Returns a list of index titles to display in the index view (e.g. ["A", "B", "C" ... "Z", "#"])
- (nullable NSArray<NSString *> *)indexTitlesForCollectionView:(UICollectionView *)collectionView API_AVAILABLE(tvos(10.2));
您可能已经阅读了 Apple 的文档,其中指出 indexTitle 方法可用于 iOS 10.3+ 和 tvOS 10.2+:https://developer.apple.com/documentation/uikit/uicollectionviewdatasource/2851455-indextitles
我尝试在 iOS 上实现它,但它不起作用,这让我相信他们在文档中犯了某种错误。
关于ios - 如何在 Collection View 中添加 indexTitles? (iOS 10+),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47772185/