Reputation: 723
I'm animating a view by showing and hiding view. I'm calling this method in didSelectRow. When I click on the cell I want to hide the view and then I want to show the view. But my problem is the animation is happening from hide to show but when not from show to hide. The show to hide is happening suddenly there is no smooth animation. I'm this code.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//[tableView deselectRowAtIndexPath:indexPath animated:YES];
Song *songObj = [songsList objectAtIndex:indexPath.row];
[self hideMsg];
//int delay = 20;
//[self performSelector:@selector(hideMsg) withObject:nil afterDelay:delay];
[self showTitleWithOptions:songObj];
}
- (void)hideMsg;
{
CGRect frame = animatedSubView.frame;//CGRectMake(0,415,360,55)
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:75];
frame.origin.y = 480;// here I'm changing y to 480
animatedSubView.frame = frame;
[UIView commitAnimations];
frame = animatedSubView.frame;// now frame is CGRectMake(0,480,360,55)
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:.75];
frame.origin.y = 415;//now I'm changing y to 415
animatedSubView.frame = frame;
[UIView commitAnimations];
theTableView.frame =CGRectMake(0,230,320,190);
}
Upvotes: 0
Views: 363
Reputation: 95
may be you can hide the view or give alpha 0.0 while its animating, and in the present view make a button action, when you click it make the present view hidden or give alpha 1.0 along with the uianimation.
Upvotes: 1
Reputation: 28720
It seems you are missing a . before the value 75 in the first animation code block "[UIView setAnimationDuration:75];" see your code again.
Update
You can not run two animations same time you need to wait for the first one to finish that is your main issue. Try running second animation after .75 duration by using
[self performSelector: withObject: afterDelay:];
method.
Upvotes: 0