Use of this method is discouraged in iOS 4.0 and later. You should use
the block-based animation methods to specify your animations instead.
我看到大量的其他方法 – 我经常使用的 – 也是“不鼓励”,这意味着他们将在iOS 6(希望),但可能最终将被弃用/删除.
为什么这些方法不鼓励?
作为附注,现在我在各种应用程序中使用beginAnimations,最常见的是在显示键盘时移动视图.
//Pushes the vIEw up if one of the table forms is selected for editing- (voID) keyboardDIDShow:(NSNotification *)aNotification{ if ([isRaised boolValue] == NO) { [UIVIEw beginAnimations:nil context:NulL]; [UIVIEw setAnimationDuration:0.25]; self.vIEw.center = CGPointMake(self.vIEw.center.x,self.vIEw.center.y-moveAmount); [UIVIEw commitAnimations]; isRaised = [NSNumber numberWithBool:YES]; }}
不确定如何使用基于块的方法来复制此功能;教程链接会很好
解决方法 因为有一个更好,更干净的选择,他们是不鼓励的在这种情况下,所有块动画都会自动将您的动画更改(例如setCenter)封装在开始和提交调用中,以便您不要忘记.它还提供了一个完成块,这意味着你不必处理委托方法.
苹果公司的文档非常好,但作为一个例子,以块的形式做同样的动画
[UIVIEw animateWithDuration:0.25 animations:^{ self.vIEw.center = CGPointMake(self.vIEw.center.x,self.vIEw.center.y-moveAmount);} completion:^(BOol finished){}];
还有ray wenderlich有一个很好的帖子块动画:link
另一种方法是考虑块动画的可能实现
+ (voID)animateWithDuration:(NSTimeInterval)duration animations:(voID (^)(voID))animations{ [UIVIEw beginAnimations]; [UIVIEw setAnimationDuration:duration]; animations(); [UIVIEw commitAnimations];}总结
以上是内存溢出为你收集整理的objective-c – 不鼓励使用beginAnimment全部内容,希望文章能够帮你解决objective-c – 不鼓励使用beginAnimment所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)