【发布时间】:2020-10-23 13:56:48
【问题描述】:
我正在使用 UITableView 来显示带有图像和标题的横幅。
youtube 链接显示过滤横幅的动画。当我按下“fav”按钮时,动画不流畅。 我想让动画流畅。
这是我的快速代码UITableView。
extension HomeViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return filteredTournamentlist.count
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let cell = tableView.dequeueReusableCell(withIdentifier: "entryCell", for: indexPath) as? TournamentEntryCell {
cell.usernameLabel.text = filteredTournamentlist[indexPath.row].master_info.name
cell.titleTabel.text = self.filteredTournamentlist[indexPath.row].name
cell.dateLabel.text = DatetimeHelper.StringFromString(
string: self.filteredTournamentlist[indexPath.row].eventDate,
fromFormat: DatetimeHelper.DBDateFormat,
toFormat: DatetimeHelper.JPStringFormat
)
cell.gameInfoLabel.text = self.filteredTournamentlist[indexPath.row].gameName
self.tournamentModel.getThumbnail(path: self.filteredTournamentlist[indexPath.row].thumbnail_path) { image in
cell.thumbnailView.image = image
}
self.profileInfoModel.getIcon(path: self.filteredTournamentlist[indexPath.row].master_info.icon_path) { icon in
cell.iconView.image = icon
}
let selectedView = UIView()
selectedView.backgroundColor = Colors.plain
cell.selectedBackgroundView = selectedView
return cell
}
return UITableViewCell()
}
}
它只是围绕横幅设置一些信息。而这个↓是collectionview的代码,显示了“fav”和“plan”等过滤按钮。
extension HomeViewController: UICollectionViewDataSource, UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 2
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "buttonCell", for: indexPath) as! PlainSquareButtonCollectionViewCell
cell.button.setTitle(fileterButtonLabels[indexPath.row], for: .normal)
let input = HomeViewModel.Input(
getHomeTournamentsTrigger: Driver.never(),
getUserInfo: Driver.never(),
filter: cell.button.rx.tap
.map { [unowned self] in
return self.fileterButtonLabels[indexPath.row]
}
.asDriverOnErrorJustComplete(),
down: cell.rx.downButton
.map { b in
return b
}.asDriverOnErrorJustComplete()
)
let output = homeViewModel.transform(input: input)
output.filteredTournamentList
.drive(onNext: { [unowned self] tournamentList in
self.filteredTournamentlist = tournamentList
self.cardTableView.reloadData()
})
.disposed(by: disposeBag)
return cell
}
}
tableView 显示filteredTournamentlist 中的所有信息,filteredTournamentlist 的内容由过滤器按钮更改。
我不知道如何使动画流畅... 帮帮我!
【问题讨论】:
标签: ios swift xcode uitableview