gpt4 book ai didi

ios - 添加动画时,UITableView 停止工作

转载 作者:行者123 更新时间:2023-11-29 05:46:25 25 4
gpt4 key购买 nike

动画好像叠加在 table 上了,就停止工作了!该视频显示,在动画尺寸较小的情况下,表格可以正常工作,但是当您添加动画尺寸时,表格将停止工作

https://drive.google.com/open?id=1nLm_uwt-AhIrJvib80lLh3ZqBH1b_SWY https://drive.google.com/open?id=15Cv4JvadTzJnB_MHG9ksCugnZqVcpgCc源项目:https://drive.google.com/open?id=1eGDZ0Z0Wf_2co2lEV9KOWE4LISC5Vogw

import UIKit
import Lottie

class MainViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

@IBOutlet weak var tableView: UITableView!

let sportMenu = ["Начать тренировку","Выбрать другую","Советы по упражнениям"]


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

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
cell?.textLabel?.text = sportMenu[indexPath.row]
return cell!


}


func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
switch indexPath.row {
case 0:
performSegue(withIdentifier: "StartTraining", sender: nil)
default:
break
}
}


@IBOutlet weak var animation: UIView!
@IBOutlet weak var settingsIcon: UIBarButtonItem!


let animationView = AnimationView()
let size: CGFloat = 540

override func viewDidLoad() {
super.viewDidLoad()

tableView.delegate = self
tableView.dataSource = self

tableView.tableFooterView = UIView()
tableView.isScrollEnabled = false


navigationController?.navigationBar.prefersLargeTitles = true
navigationItem.largeTitleDisplayMode = .automatic

let animation = Animation.named("Espander")
animationView.animation = animation
animationView.play()
animationView.loopMode = .loop

animationView.frame = CGRect(x: 0, y: 0, width: size, height: size)
animationView.contentMode = .scaleAspectFit
view.addSubview(animationView)

animationView.translatesAutoresizingMaskIntoConstraints = false
animationView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor, constant: -120).isActive = true
animationView.heightAnchor.constraint(equalToConstant: size).isActive = true
animationView.widthAnchor.constraint(equalToConstant: size).isActive = true
animationView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor).isActive = true


}

最佳答案

可能你的animationView正在吸收点击,所以这就是tableView不响应的原因。

只需添加animationView.isUserInteractionEnabled = false

关于ios - 添加动画时,UITableView 停止工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56115845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com