issue while changing the CurrentPage of UIPageControl which is Inside a TableViewCell

am trying to create a Carousel inside tableViewCell and am almost there but am having difficulty while implementing the UIPageControl in my TableView so that when CollectionViewCell’s (which is inside tableViewCell) Item got changed i can show it on UIPageControl,

i tried the below solution and encountered a strange behaviour (maybe its strange for only me ) , when the View Loads and i change my item (which is in collectionViewCell) the PageControl’s currentPage is not changing but after scrolling down to the end of tableView and coming back to top its working fine ,

  • Is that possible to use UIPageControl to control the move of UITableView?
  • Reduce dot size or padding to fit all page indicators on screen with UIPageControl
  • UIPageControl - Change page on click of button
  • UICollectionView: current index path for page control
  • how do i use a UIPageControl?
  • Page count of UICollectionView with paging in iOS
  • suppose you have 6 rows and you scroll down to row 6 and then when you scroll up to row 5 and change its item the pageControl will work , if you keep doing this until reaching the top it’ll going to work fine but if you go from row 5 to 6 and change row 6’s item then its not going to work

    i am initialising my pageControl in cellForRowAtIndexPath :

      pagerControll = cell.pageControll
    

    then trying to change the position by listening to ScrollView’s contentOffSet

    override func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
    
    if scrollView != tableView {
    
        if scrollView.contentOffset.x >= self.view.frame.size.width && scrollView.contentOffset.x < (self.view.frame.size.width * 2){
    
            pagerControll.currentPage = 1
        }else if  scrollView.contentOffset.x >= (self.view.frame.size.width * 2 )  {
            pagerControll.currentPage = 2
    
        }else {
    
            pagerControll.currentPage = 0
        }
    
        print(scrollView.contentOffset) }
    }
    

    any idea why this is happening ?? or how to fix this ??

    P.s if question is not clear enough then let me know , i’ll add some more detail

    UPDATE:

    when view loads and am changing the item of collectionViewCell the below cell’s pageControl’s currentPage is Changing

    Solutions Collect From Internet About “issue while changing the CurrentPage of UIPageControl which is Inside a TableViewCell”

    after getting pissed off , WE MADE IT

        override func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
    
            if scrollView != tableView {
    
               let currentCells =  tableView.visibleCells
                let cell = currentCells[0] as! NotesTableViewCell
    
                if scrollView.contentOffset.x >= self.view.frame.size.width && scrollView.contentOffset.x < (self.view.frame.size.width * 2){
    
                    cell.pageControll.currentPage = 1
                }else if  scrollView.contentOffset.x >= (self.view.frame.size.width * 2 )  {
    
                    cell.pageControll.currentPage = 2
    
                }else {
    
                    cell.pageControll.currentPage = 0
                }
            }
    
        }
    

    enter image description here