【发布时间】:2011-06-24 06:59:31
【问题描述】:
我通过显示和隐藏视图来为视图设置动画。我在 didSelectRow 中调用此方法。 当我单击单元格时,我想隐藏视图,然后我想显示视图。但我的问题是动画是从 hide 到 show 发生的,但不是从 show 到 hide。隐藏的节目突然发生,没有流畅的动画。我就是这个代码。
- (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);
}
【问题讨论】:
标签: objective-c ios4