анимировать строку tableView, выбрав ячейку collectionView - PullRequest
0 голосов
/ 28 ноября 2018

Я установил еженедельный календарь с датами в collectionView.Ниже этой коллекции вид таблицы.При выборе любой даты в collectionView tableView фильтрует данные, которые работают нормально.

Моя проблема заключается в том, что я пытаюсь анимировать строки tableView в соответствии с выбором ячейки, т. Е. Если я выбираю следующую дату (илиячейка), я хочу сделать следующее:

tableView.reloadRows(at: visibleRows, with: .left)

И если я выберу предыдущую дату (или ячейку), я хочу:

tableView.reloadRows(at: visibleRows, with: .right)

Ниже приведен код.Любая помощь приветствуется.

нажмите здесь, чтобы увидеть экран приложения gif

В collectionView:

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as! WeekHeaderViewCell
        cell.labelDate.text = calendarDateArray?[indexPath.row] as? String
        return cell
    }

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        let selectedRow = getCalendar().setArray("dd MMMM yyyy")[indexPath.row] as? String
        let dateFromString = getCalendar().df.date(from: selectedRow!)
        mainCell?.fetchFilteredData(dateFromString!)
        mainCell?.animateRows(animation: .left) // **help needed here**
    }

В tableView:

func fetchFilteredData(_ date: Date) {
        resultsController.fetchRequest.predicate = NSPredicate(format: "(taskTime => %@) AND (taskTime <= %@)", DateHelper.startOfDay(day: date as NSDate), DateHelper.endOfDay(day: date as NSDate))
        fetchData()
    }

    func animateRows(animation: UITableView.RowAnimation) {
        tableView.reloadData()
        if let visibleRows = tableView.indexPathsForVisibleRows {
            tableView.reloadRows(at: visibleRows, with: animation)
        }
    }
...