Created
June 9, 2013 14:56
-
-
Save kommen/5743831 to your computer and use it in GitHub Desktop.
Queue presentViewController and dismissViewControllerAnimated with dispatch semaphores.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void) queueViewControllerTransition:(BOOL)show { | |
static dispatch_queue_t presentAndDismissViewControllerQueue; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
presentAndDismissViewControllerQueue = dispatch_queue_create("presentAndDismissViewControllerQueue", DISPATCH_QUEUE_SERIAL); | |
}); | |
dispatch_async(presentAndDismissViewControllerQueue, ^{ | |
dispatch_semaphore_t sema = dispatch_semaphore_create(0); | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
if (show) { | |
[self presentViewController:self.yourViewController animated:YES completion:^{ | |
dispatch_semaphore_signal(sema); | |
}]; | |
} else{ | |
[self dismissViewControllerAnimated:YES completion:^{ | |
dispatch_semaphore_signal(sema); | |
}]; | |
} | |
}); | |
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment