【发布时间】:2017-09-30 20:34:07
【问题描述】:
我尝试在 viewController 中添加 pageControl 以显示 当前页面 和 总页面。
我在 viewController 中有 collectionView。但是如果我在 viewController 中添加 @IBOutlet 我会得到 error:
“从 DetailViewController 到 UIPageControl 的 pageControl 出口无效。出口无法连接到重复内容。”
这意味着重复内容?
我知道这个问题已被问过很多次,但我尝试了建议但没有任何帮助。
main.storyboard 中的PageControl 只有一个@IBOutlet,它会引发错误...
如果需要我的代码,他在这里:
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(我不知道如何更好)?
【问题讨论】:
标签: swift io uicollectionview iboutlet uipagecontrol