Skip to content

Instantly share code, notes, and snippets.

@kommen
Created June 9, 2013 14:56
Show Gist options
  • Select an option

  • Save kommen/5743831 to your computer and use it in GitHub Desktop.

Select an option

Save kommen/5743831 to your computer and use it in GitHub Desktop.

Revisions

  1. kommen created this gist Jun 9, 2013.
    23 changes: 23 additions & 0 deletions gistfile1.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    - (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);
    });
    }