Wie die pageControl im Collectionview Innerhalb der Tableview?

In meinem Projekt habe ich eine tableView innerhalb einer collectionView und auch ich verwendete ein pageControl. Wenn ich das streichen der Sammlung anzeigen, horizontal, möchte ich wechseln pageControl auch, aber es funktioniert nicht richtig. Ich verwendet scrollViewDidScroll Methode für die Umschaltung der pageControl als collectionView Klaut. Aber das problem ist, wenn der tableView scrolls scrollViewDidScroll - Methode erneut aufrufen. So ist es eine andere Art oder keine Lösung für dieses Problem zu beheben.

Überprüfen Sie den untenstehenden link.

geben Sie den link-Beschreibung hier

TableView-Methode

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
{
     return model.count
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 
{
     cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! FbHomeCell
     cell.btnPushImage.tag = indexPath.row
     cell.collectionView.tag = indexPath.row
     return cell
}

Methode CollectionView

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
{
     return model[collectionView.tag].count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell
{
      collCell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! FBHomeCollectionCell    
      collCell.backgroundColor = model[collectionView.tag][indexPath.item]    
      collCell.pageControlSwipe.numberOfPages = Int(collectionView.contentSize.width/collectionView.frame.size.width)                       
      return collCell
 }

Scroll-View Delegate-Methode

func scrollViewDidScroll(_ scrollView: UIScrollView)
{
     let pageWidth = scrollView.frame.width
     collCell.pageControlSwipe.currentPage = Int((scrollView.contentOffset.x + pageWidth / 2) / pageWidth)

     collCell = cell.collectionView.cellForItem(at: IndexPath (item: scrollView.tag, section: 0)) as! FBHomeCollectionCell

 }

Dank und Schätzen für die Hilfe..

InformationsquelleAutor ashmi123 | 2016-12-21
Schreibe einen Kommentar