2023-07-18 关于在View获取当前VC push 到 另外VC,popViewController 发生卡界面的记录

View 的Push 方法:

   if let tabVC = UIApplication.shared.keyWindow?.rootViewController as? UITabBarController,

        let navi = tabVC.selectedViewControlleras?UINavigationController{

            let playVC =BCPlayerViewController()

            playVC.hidesBottomBarWhenPushed = true

            navi.pushViewController(playVC,animated:true)

        }

问题:当在 BCPlayerViewController popViewController 回去时出现界面卡顿

原因:BCPlayerViewController 上添加了一个UIImageView :

 bgImageView.frame = CGRectMake(0, 0,kScreenWidth, kScreenHeight)

 bgImageView.sd_setImage(with: NSURL(string: BCPlayerManager.shared.player?.songModel.albumimg ?? "") as URL?,       placeholderImage: UIImage(named: "lost_icon"))

bgImageView.contentMode = .scaleAspectFill

 view.addSubview(bgImageView)

 解决方式:在popViewController 之前,移除这个UIImageView

  bgImageView.removeFromSuperview()

   self.navigationController?.popViewController(animated: true)

另:真正的原因是这一句:bgImageView.sd_setImage(with: NSURL(string: BCPlayerManager.shared.player?.songModel.albumimg ?? "") as URL?,       placeholderImage: UIImage(named: "lost_icon")) 取消了就没事了。原因不明。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容