Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extension ProductListCell {
- func setCollectionViewDataSourceDelegate<D: JTAppleCalendarViewDataSource & JTAppleCalendarViewDelegate>(_ dataSourceDelegate: D, forRow row: Int) {
- CalenderCollectionView.calendarDelegate = dataSourceDelegate
- CalenderCollectionView.calendarDataSource = dataSourceDelegate
- CalenderCollectionView.tag = row
- CalenderCollectionView.setContentOffset(CalenderCollectionView.contentOffset, animated:false)
- CalenderCollectionView.reloadData()
- }
- var collectionViewOffset: CGFloat {
- set { CalenderCollectionView.contentOffset.x = newValue }
- get { return CalenderCollectionView.contentOffset.x }
- }
- }
- func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
- print("will display cell")
- if((indexPath.row+1)/10 == self.pageNumber && self.pageNumber < self.TotalPages){
- self.pageNumber+=1
- self.ApiCallforCategoryData()
- }
- guard let tableViewCell = cell as? ProductListCell else { return }
- tableViewCell.setCollectionViewDataSourceDelegate(self, forRow: indexPath.row)
- tableViewCell.collectionViewOffset = storedOffsets[indexPath.row] ?? 0
- }
- func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
- print("did end displaying cell")
- guard let tableViewCell = cell as? ProductListCell else { return }
- storedOffsets[indexPath.row] = tableViewCell.collectionViewOffset
- }
Add Comment
Please, Sign In to add comment