I have a UIView
property named viewToFade
that contains a UISegmentedControl
. When I animate the UIView
(so it appears on tapping and gradually fades), the UISegmentedControl
doesn't respond to touches. Here's the code I'm using:
-(void)fadeView
{
self.viewToFade.alpha=1;
self.viewToFade.hidden=NO;
//When I comment the following lines out, everything is fine--the `UISegmentedControl` responds as it should.
//But when I include them, the `UISegmentedControl` doesn't register changes/taps.
[UIView animateWithDuration:0.3
delay: 3.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.viewToFade.alpha = 0.0;
}
completion:nil];
}
What am I doing wrong?
(In case it's relevant, I'll say that the UIView
and the UISegmentedControl
are both created in the xib file.)
EDIT: I figured out a way to deal with the problem, which was to rewrite the code as follows:
-(void)fadeView
{
self.viewToFade.alpha=1;
self.viewToFade.hidden=NO;
[self performSelector:@selector(disneyfy) withObject:nil afterDelay:(3)];
}
-(void)disneyfy
{
[UIView animateWithDuration:0.3
animations:^{
self.viewToFade.alpha = 0.0;
}];
}