添加动画时,UitableView停止工作



动画似乎在桌子上叠加,并且停止工作!视频显示,桌子尺寸较小,表可以正常工作,但是当您添加动画的大小时,表停止工作

https://drive.google.com/open?id=1nlm_uwt-ahirjvib80llh3zqbh1b_swyhttps://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

 }

可能您的动画视图吸收了水龙头,因此TableView不响应。

只需添加animationView.isUserInteractionEnabled = false

最新更新