Reputation: 588
I initialized my screen and all the elements in viewDid
load, hidden them and set to reveal them after parsing JSON, I have a collectionView
in a scrollView
inside which I synchronically load elements that I dowloaded. Downloading and parsing JSON takes less than a sec, but for my screen to show up it takes a lot, but funny thing is when I try to scroll the screen it appears instantly, so I think that something is up with either scrollView
or collectionView
that I am not aware of. Anyone had a similar situation?
collectionView.dataSource = self is in the .hidden = false function
there is a lot of code, I am not sure that it would be very helpful.
Upvotes: 0
Views: 33
Reputation: 588
for swift it worked by wraping the func that unhides the elements just after parsing JSON with:
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
dispatch_async(dispatch_get_main_queue()) {
self.loadScreen()
}
})
thanx iremk for the objective c eqvivalent :)
Upvotes: 0
Reputation: 677
Try creating a new function to update your view's hidden elements and then call it like :
[self performSelectorOnMainThread:@"your-selector" withObject:nil waitUntilDone:YES]
Because in async calls view updates won't be affective time-to-time.
I hope this helps!
Upvotes: 1