页面控制在完全转到下一页之前切换页面

问题描述 投票:0回答:1

我已经为集合视图创建了页面控件,每个集合视图单元格都是屏幕的高度和宽度。这是页面控件的设置:

// Setup the page control
func setupPageControl() {

    pageControl.pageIndicatorTintColor = cellColor
    pageControl.currentPageIndicatorTintColor = themeColor

    view.addSubview(pageControl)
    addPageControlConstraints()
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    pageControl.numberOfPages = collectionViewCellData.count
    return collectionViewCellData.count
}

func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
    pageControl.currentPage = indexPath.row
}

页面控件有一个小问题,请检查一下:

Screen recording

注意,当我什至还没有完全转到下一页时,页面控件将如何更改,如何解决此问题?

ios swift uicollectionview uipagecontrol
1个回答
0
投票

您需要使用UIPageViewControllerDelegate的方法“ didFinishAnimating:previousViewControllers:transitionCompleted:”,并使用transitionCompleted布尔值来帮助您更新页面]]

© www.soinside.com 2019 - 2024. All rights reserved.