我在滚动视图中的内容上制作了动画,但内存有问题。所以我有 UITabBarController,在 3 个选项卡中我有一个自定义 UIView,它有一个 UIScrollView。我用它来动画水平内容滚动:
- (void)beginAnimation
{
if (isAnimating) {
return;
}
[scrollView setContentOffset:[self startOffset]];
isAnimating = YES;
NSTimeInterval animationDuration = (scrollView.contentSize.width / self.tickerSpeed);
[UIView animateWithDuration:animationDuration
delay:0
options:UIViewAnimationOptionCurveLinear
animations:^{
CGPoint finalPoint = CGPointZero;
if (self.scrollingDirection == BBScrollingDirectionFromRightToLeft) {
finalPoint = CGPointMake(scrollView.contentSize.width, 0);
} else if (self.scrollingDirection == BBScrollingDirectionFromLeftToRight) {
finalPoint = CGPointMake(-scrollView.contentSize.width + self.frame.size.width, 0);
}
scrollView.contentOffset = finalPoint;
} completion:^(BOOL finished) {
isAnimating = NO;
[self beginAnimation];
}];
}
当我启动应用程序并位于第一个选项卡时,一切正常,但是当我切换到另一个选项卡时,仪器分配中的总字节数开始快速增长,实时字节数几乎相同。有人可以解释一下发生了什么吗?