gpt4 book ai didi

swift - IBOutlet pageControl 无效

转载 作者:行者123 更新时间:2023-11-30 12:07:30 27 4
gpt4 key购买 nike

我尝试在viewController中添加pageControl以显示当前页总页

我在viewController内有collectionView。但是如果我在 viewController 中添加 @IBOutlet 我会得到错误:

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

这意味着重复内容?

我知道这个问题已被问过很多次,但我尝试了建议的内容,但没有任何帮助。

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
}
}

我如何在collectionView或collectionCell中添加pageControll(我不知道如何更好)?

最佳答案

我也遇到了同样的问题。这是因为您的页面控件是单元格的 subview 。你不可以做这个。

  1. 将其从牢房中取出
  2. 将其放在您的主视图/安全区域

关于swift - IBOutlet pageControl 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46506811/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com