Guest User

Untitled

a guest
Jul 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. extension ProductListCell {
  2.  
  3. func setCollectionViewDataSourceDelegate<D: JTAppleCalendarViewDataSource & JTAppleCalendarViewDelegate>(_ dataSourceDelegate: D, forRow row: Int) {
  4.  
  5. CalenderCollectionView.calendarDelegate = dataSourceDelegate
  6. CalenderCollectionView.calendarDataSource = dataSourceDelegate
  7. CalenderCollectionView.tag = row
  8. CalenderCollectionView.setContentOffset(CalenderCollectionView.contentOffset, animated:false)
  9. CalenderCollectionView.reloadData()
  10. }
  11.  
  12. var collectionViewOffset: CGFloat {
  13. set { CalenderCollectionView.contentOffset.x = newValue }
  14. get { return CalenderCollectionView.contentOffset.x }
  15. }
  16. }
  17.  
  18. func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
  19.  
  20. print("will display cell")
  21. if((indexPath.row+1)/10 == self.pageNumber && self.pageNumber < self.TotalPages){
  22.  
  23. self.pageNumber+=1
  24. self.ApiCallforCategoryData()
  25. }
  26.  
  27. guard let tableViewCell = cell as? ProductListCell else { return }
  28. tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.row)
  29. tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? 0
  30. }
  31.  
  32.  
  33. func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
  34.  
  35. print("did end displaying cell")
  36. guard let tableViewCell = cell as? ProductListCell else { return }
  37. storedOffsets[indexPath.row] = tableViewCell.collectionViewOffset
  38. }
Add Comment
Please, Sign In to add comment