IBOutlet pageControl无效

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

我试图在viewController中添加pageControl以显示当前页面和总页面。

我在viewController里面有collectionView。但是,如果我在viewController中添加@IBOutlet,我会收到错误:

“从DetailViewController到UIPageControl的pageControl出口无效.Outlet无法连接到重复内容。”

这意味着重复内容?

我知道这个问题已被多次询问,但我尝试了所建议但没有任何帮助。

main.storyboard中的PageControl只有一个@IBOutlet,它会抛出一个错误... pageControl

如果需要我的代码,他在这里:

class DetailViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UITableViewDelegate, UITableViewDataSource {

    // MARK: - IBOutlet's
    @IBOutlet weak var collectionView: UICollectionView!
    @IBOutlet weak var tableView: UITableView!

    @IBOutlet weak var pageControl: UIPageControl!

    var hallImages: Hall?

    var currentPage = 0

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func viewWillAppear(_ animated: Bool) {
        tableView.estimatedRowHeight = 626
        tableView.rowHeight = UITableViewAutomaticDimension

    }
    // MARK: - CollectionView
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        guard let imagesHall = hallImages?.ImagesHalls.count else {
            return 0
        }
        return imagesHall
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! DetailCollectionViewCell

        if let imagesHalls = hallImages?.ImagesHalls[indexPath.item] {
            cell.imageView.sd_setImage(with: URL(string: imagesHalls))
        }

        return cell
    }
}

如何在uicollectionView或集合Cell中添加pageControl(我不知道如何更好)?

swift io uicollectionview iboutlet uipagecontrol
1个回答
0
投票

我有同样的问题。这是因为您的页面控件是单元格的子视图。你不能做这个。

  1. 把它带出你的牢房
  2. 把它放在你的主视图/安全区域
© www.soinside.com 2019 - 2024. All rights reserved.