你在正确的道路上。 当您在UIPageViewController
上滑动时,您将获得当前页面索引。您应该将该索引保存到类变量中,并在cellForItemAtIndexPath
中使用它来确定当前显示的选项卡索引是否匹配UIPageViewController
。所以,这样的事情应该工作:
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("reuseIdentifier", forIndexPath: indexPath)
if indexPath.item == classIndexVariable {
bottomIndicator.isHidden = false // show indicator at current position
}else{
bottomIndicator.isHidden = true // hide indicator from all only shows in matched condition
}
return cell
}
解释道: 在cellForItemAtIndexPath
你要比较你UIPageViewController didFinishAnimating
功能保存指数当前单元格的索引。如果它匹配你有活动标签 - 显示底部指标。如果索引不匹配,则您的选项卡未激活,因此不显示底部指示符。
正如我所说,请记住,这只是一个snipper。不知道你的代码是什么样的,我猜你正在做这样的事情。
我做了正确的U说U给了正确的解决方案它为我工作谢谢 – User