Objective c 在iphone sdk中设置视图动画时出现问题?
我正在通过显示和隐藏视图来设置视图的动画。我正在didSelectRow中调用此方法。 单击单元格时,我希望隐藏视图,然后显示视图。但我的问题是动画是从隐藏到显示的,而不是从显示到隐藏的。要隐藏的显示突然发生,没有平滑动画。我是这个密码Objective c 在iphone sdk中设置视图动画时出现问题?,objective-c,ios4,Objective C,Ios4,我正在通过显示和隐藏视图来设置视图的动画。我正在didSelectRow中调用此方法。 单击单元格时,我希望隐藏视图,然后显示视图。但我的问题是动画是从隐藏到显示的,而不是从显示到隐藏的。要隐藏的显示突然发生,没有平滑动画。我是这个密码 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //[tableView deselectRowAtI
- (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);
}
看来你错过了一个机会。在第一个动画代码块“[UIView setAnimationDuration:75];”中的值75之前,请再次查看代码 更新 您不能同时运行两个动画,您需要等待第一个动画完成,这是您的主要问题。尝试在.75持续时间后使用运行第二个动画
[self performSelector: withObject: afterDelay:];
方法。可能是,您可以在设置动画时隐藏视图或给出alpha 0.0,并且在当前视图中,当您单击它时,可以制作一个按钮动作,使当前视图隐藏或在uianimation中给出alpha 1.0。嘿,Srry,我在这里粘贴代码时错过了它。我只保留了0.75美元。