[英]Swift dismissing view with clunky animation
I simply have a ViewController
that I would like to dismiss
.我只是有一个我想
dismiss
的ViewController
。 And this is my dismissAction
:这是我的
dismissAction
:
@objc private func dismissView(){
self.dismiss(animated: true, completion: nil)
UserDefaultsService.shared.updateDataSourceArrayWithWishlist(wishlist: self.wishList)
let dataSourceArray = UserDefaultsService.shared.getDataSourceArray()
// update datasource array in MainVC
self.dismissWishlistDelegate?.dismissWishlistVC(dataArray: dataSourceArray, dropDownArray: self.dropOptions, shouldDeleteWithAnimation: false, wishlistToDelete: self.wishList)
}
Proble:问题:
The dismiss animation is very clunky
and not fluent at all.解雇 animation 非常
clunky
,根本不流利。 I found out that if I remove everything in the function but only call self.dismiss
it is working perfectly fine.我发现如果我删除 function 中的所有内容但只调用
self.dismiss
它工作得很好。 What is the issue here?这里有什么问题? Any idea on how I can fix this?
关于如何解决这个问题的任何想法?
You can try to light-weight load in main thread by您可以尝试通过
DispatchQueue.global().async {
UserDefaultsService.shared.updateDataSourceArrayWithWishlist(wishlist: self.wishList)
}
And instead of let dataSourceArray = UserDefaultsService.shared.getDataSourceArray()
use self.wishList
directly in the last line而不是
let dataSourceArray = UserDefaultsService.shared.getDataSourceArray()
在最后一行直接使用self.wishList
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.