Reputation: 725
I want to create a custom tableViewCell
with a PageViewControl
on it. I want the user to be able to swipe on the cell to change the views. This is my code:
override func awakeFromNib() {
super.awakeFromNib()
self.isUserInteractionEnabled = true
pageControl.isUserInteractionEnabled = true
self.backgroundColor = UIColor.darkGray
setupPageControl()
}
private func setupPageControl() {
pageControl.numberOfPages = 7
pageControl.translatesAutoresizingMaskIntoConstraints = false
pageControl.currentPageIndicatorTintColor = UIColor.orange
pageControl.pageIndicatorTintColor = UIColor.lightGray.withAlphaComponent(0.8)
}
The problem is that the view does change only by tapping on it, and not swiping. The second problem is that the pageControl
dots are in the middle of the screen and not on the bottom.
Upvotes: 1
Views: 473
Reputation: 955
The page control does not detect swipes by itself. You can tap on the side to switch the page.
If you want to change with swipes you need to add a swipe gesture recongnizer to your cells Or Use a horizontal collection view with paging enabled. Then you can use delegates to connect the page control to the collection view, so that they can update each other
Upvotes: 1