Note that there are some explanatory texts on larger screens.

plurals
  1. POAlpha changing instantly with UIView animateWithDuration: instead of animating
    primarykey
    data
    text
    <p>I'm attempting to fade in a UIView that I've created by animating the alpha. I need to fade it in, leave it visible for a few seconds, then fade it out.</p> <p>The fade out function works fine. The view smoothly disappears. But the fade in just makes the view appear instantly instead of slowly appearing over an interval of 0.5 seconds.</p> <p>So it seems like the fade in animation isn't working, just instantly setting the alpha to <code>1.0</code>. I'm kind of at a loss here. Any ideas what I'm doing wrong? Thanks!</p> <pre><code>-(void)presentPopupPhrase:(NSString *)phrase inView:(UIView *)view withDelegate:(id)delegate andCompletion:(void (^)(BOOL completed))completion { MessagePopupView *pv = [[[MessagePopupView alloc] initWithFrame:self.frame andText:phrase] autorelease]; pv.alpha = 0.0; [view addSubview:pv]; [self fadeInMPV:pv withDuration:self.fadeDuration andDelay:self.fadeInDelay]; [self fadeOutMPV:pv withDuration:self.fadeDuration afterDelay:self.fadeOutDelay withCompletion:completion andDelegate:delegate]; } -(void)fadeInMPV:(MessagePopupView *)mpv withDuration:(NSTimeInterval)duration andDelay:(NSTimeInterval)delay { [UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionCurveLinear animations:^{ mpv.alpha = 1.0; } completion:nil]; } -(void)fadeOutMPV:(MessagePopupView *)mpv withDuration:(NSTimeInterval)duration afterDelay:(NSTimeInterval)delay withCompletion:(void (^)(BOOL completed))completion andDelegate:(id)delegate { [UIView animateWithDuration:duration delay:delay options:UIViewAnimationOptionCurveLinear animations:^{ mpv.alpha = 0.0; } completion:completion]; } </code></pre> <p><strong>EDIT:</strong></p> <p>If it helps, here's the VC code where I'm calling it from:</p> <pre><code>-(void)viewDidAppear:(BOOL)animated { CGRect phraseFrame = CGRectMake(20, 341, 280, 65); PopupPhraseController *phraseController = [[[PopupPhraseController alloc] initWithFrame:phraseFrame] autorelease]; [phraseController presentPopupPhrase:@"Test Phrase" inView:self.view withDelegate:self andCompletion:^(BOOL completed){ if (completed) { NSLog(@"completed"); } else { NSLog(@"not completed"); } NSLog(@"blocked!"); }]; [super viewDidAppear:animated]; } </code></pre>
    singulars
    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