Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom segue animating with delay after code being run. (Objective C)
    primarykey
    data
    text
    <p>I have several <code>dispatch_async</code> methods linked so they authenticate a user in my system.</p> <p>The next async method only happens when the previous one finishes, as they each have completion handlers.</p> <p>When the last one is finished I perform a custom segue with 2 <code>uiview</code> animation blocks.</p> <p>However, when I log when each of these actually run, there is a considerable gap between the log and the animation actually happening, eventually the views animate and the completion block is called.</p> <p>I don't really know how useful it would be adding my code here, but i have tested and it must be the async methods because if I comment them out and just return <code>YES</code> the animations happen without delay at the same time as the log.</p> <p>Does anyone know why this might happen?</p> <p><strong>EDIT *(with code)</strong></p> <p>Typical 'exist check' used for email, user, user id.</p> <pre><code>- (void)existsInSystemWithCompletionHandler:(void (^)(BOOL))block { self.existsInSystem = NO; if (self.isValid) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // // Get data // if (dataIsValid) { block(YES); } else { block(NO); } }); } else { block(self.existsInSystem); } } </code></pre> <p>Check user exists</p> <pre><code>[potentialUser existsInSystemWithCompletionHandler:^(BOOL success) { if (success) { // Perform segue // [self performSegueWithIdentifier:@"Logging In" sender:self]; } }]; </code></pre> <p>Segue</p> <pre><code>- (void)perform { NSLog(@"Perform"); LogInViewController *sourceViewController = (LogInViewController *)self.sourceViewController; LoggingInViewController *destinationViewController = (LoggingInViewController *)self.destinationViewController; destinationViewController.user = sourceViewController.potentialUser; // Animate // [UIView animateWithDuration:0.2f animations:^{ NSLog(@"Animation 1"); // // Animate blah blah blah // }]; [UIView animateWithDuration:0.4f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{ NSLog(@"Animation 2"); // // Animate blah blah blah // } completion:^(BOOL finished) { NSLog(@"Completion"); // // Finished // [sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; }]; } </code></pre> <p>LoggingIn VC</p> <pre><code>- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [self.user loginWithCompletionHandler:^(BOOL success) { if (success) { [self performSegueWithIdentifier:@"Logged In" sender:self]; } }]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload