简体   繁体   中英

Load data with Core Data in UICollectionView before animation

I am pretty new to iOS development, but I could not find an answer to this question (maybe I could not find the right keywords to search..?).

Anyway, I have this "problem":

I have 2 storyboards, A and B, both with some views inside. I go from view A-2 to view B-1 via @IBAction - a simple button click - with the following code:

 @IBAction func onExercisesButtonTapped(_ sender: AnyObject) {
    let storyboard = UIStoryboard(name: "Exercises", bundle: nil)
    let controller = storyboard.instantiateViewController(withIdentifier: "ExercisesVC") as UIViewController

    controller.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
    present(controller, animated: true, completion: nil)    
}

On the other hand, in the B-1 view I have a UICollectionView that is populated with data coming from a CoreData model. The cells within the UICollectionView appear only after the animation is completed. If I set animated: false in the perform function and thus no animation is performed from A-2 view to B-1 view the cells are immediately visible.

The cells are the only element that appear after the completion of the animation. What is the cause of this behaviour? Can I avoid it with some sort of preloading/prefetching or other methods?

Is there a way to display the cells before the animation starts, just like the UICollectionView background and all the other elements within the view?

Thank you in advance :)

viewWillAppear:更新视图。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM