0
我正在开发一个Cocos2D游戏。在舞台上展示一个UIView,给用户一个执行任务的列表。有使用动画向上或向下移动的文本字段。我的代码如下。即使在调用commitAnimation之后,动画仍然影响每个视图
[textField setFrame:CGRectMake(textField.frame.origin.x, textField.frame.origin.y, textField.frame.size.width, textField.frame.size.height)];
[inviteButton setFrame:CGRectMake(inviteButton.frame.origin.x, inviteButton.frame.origin.y, inviteButton.frame.size.width, inviteButton.frame.size.height)];
[headingLabel setFrame:CGRectMake(headingLabel.frame.origin.x, headingLabel.frame.origin.y, headingLabel.frame.size.width, headingLabel.frame.size.height)];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
[UIView setAnimationDelegate:self];
[textField setFrame:CGRectMake(textField.frame.origin.x, textField.frame.origin.y-50, textField.frame.size.width, textField.frame.size.height)];
[inviteButton setFrame:CGRectMake(inviteButton.frame.origin.x, inviteButton.frame.origin.y-50, inviteButton.frame.size.width, inviteButton.frame.size.height)];
[headingLabel setFrame:CGRectMake(headingLabel.frame.origin.x, headingLabel.frame.origin.y-30, headingLabel.frame.size.width, headingLabel.frame.size.height)];
[UIView commitAnimations];
[self.view.layer removeAllAnimations];
问题是,用户完成他按下取消按钮删除超级鉴于这种观点后,也包括UIAlertView中,并出现在我的地图中删除这一观点之后其它子视图每个视图是由动画影响我曾经移动文本字段和标签向上或向下。 UIAlertView使用相同的动画显示,所以正在发生其他子视图。任何人都可以告诉我为什么会发生这种情况?
问候
我得到了解决方案。感谢basvk。我其实犯了一个错误。在设置UI组件的框架之前,我正在调用[UIView commitAnimations]。 – Aqueel 2012-02-01 11:57:35