I am trying to complete a task, and then want the xib content to be shown on the view. However the VC is being initialized via nibFile, is there a way to do lazy loading of nib once the task is completed?
Thanks
I am trying to complete a task, and then want the xib content to be shown on the view. However the VC is being initialized via nibFile, is there a way to do lazy loading of nib once the task is completed?
Thanks
in viewDidLoad:
self.view.hidden = YES;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// do your background tasks here
[self doSomethingInBackground];
// when that method finishes you can run whatever you need to on the main thread
dispatch_async(dispatch_get_main_queue(), ^{
self.view.hidden = NO;
});
});
(adapted from Implement a block in background, then after completion run another block on main thread?)
Put the task in a background thread, when this finish refresh the main thread to load the nib.
Remember, the view in iOS application run in Main thread, if you are doing a task and this no finish quickly, the best way is run the task in background.