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

标签 ios swift uitableview

动画好像叠加在 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/

相关文章:

ios - 使 UIImageView 适合屏幕宽度但保持宽高比 [swift]

java - 如何为 iOS 推送通知传递 JSON 对象

ios - 当应用程序在前台时检测用户何时点击通知

ios - iPad 上自定义 UITableViewCell 顶部的灰线

ios - Realm - 订购元素?

从 URL 进行 Swift JSON 解码

swift - UITableViewController 和预取

ios - Swift AppDelegate 应用程序 :didFinishLaunchingWithOptions error

ios - 使用 plistbuddy 从 plist 中的字典中读取所有键

ios - 如何更改sendSynchronousRequest:urlRequest,因为已弃用