hi,
i am following an example from apple (HeadsUpDisplay), which is bringing up one HUD (alpha and position). now i expanded that example to change 2 views at the same time. the first view is doing fine but the second one acts like he has a hiccup. it doesn't fade in the alpha and the position animation is much faster than the first one. here's the code:
- (void)showHoverViews:(BOOL)show
{
// reset the timer
[myTimer invalidate];
[myTimer release];
myTimer = nil;
// fade animate the view out of view by affecting its alpha
[UIView beginAnimations :nilcontext:NULL];
[UIView setAnimationDuration:0.40];
if (show)
{
// as we start the fade effect, start the timeout timer for automatically hiding HoverView
editHoverView.alpha = 1.0;
CGRect frame = editHoverView.frame;
frame.origin.y = self.view.frame.size.width - frame.size.height;
editHoverView.frame = frame;
infoHoverView.alpha = 1.0;
frame = infoHoverView.frame;
frame.origin.y = 0;
infoHoverView.frame = frame;
myTimer = [[NSTimer timerWithTimeInterval : 3.0target:selfselector:@selector(timerFired:) userInfo:nil repeats:NO] retain];
[[NSRunLoop currentRunLoop] addTimer:myTimer forMode:NSDefaultRunLoopMode];
}
else
{
CGRect frame = editHoverView.frame;
frame.origin.y = self.view.frame.size.width;
editHoverView.frame = frame;
editHoverView.alpha = 0.0;
frame = infoHoverView.frame;
frame.origin.y = 0 - self.view.frame.size.width;
infoHoverView.frame = frame;
infoHoverView.alpha = 0.0;
}
[UIView commitAnimations];
}
- (void)timerFired:(NSTimer *)timer
{
// time has passed, hide the HoverView
[self showHoverViews: NO];
}