在我的 iOS 应用程序中,我有一些动画似乎不知从何而来。它们一开始不会发生,只有在稍微使用该应用程序后才会发生。这是一个有更好描述的 Youtube 视频:
http://www.youtube.com/watch?v=whfG67EP6kk
我不太确定为什么这些元素会以它们(或根本)的方式进行动画处理。我调用的代码只是一个简单的 [view addSubView:viewname]。关于这种情况如何发生以及如何防止它的任何帮助都会很棒。
编辑 这是从看似四面八方飞来的文本的代码:
-(void)displayPublicDataForEntry:(PFObject *)entry likes:(unsigned long)likesCount comments:(unsigned long)commentsCount
{
[indicator stopAnimating];
[indicator removeFromSuperview];
[zippingLabel removeFromSuperview];
entryStatus.text = @"This entry is public";
entryStatus.backgroundColor = [UIColor clearColor];
entryStatus.frame = CGRectMake(10, 3, 200, 20);
[shareView addSubview:entryStatus];
// Display a UILabel of number of likes
if (likesCount == 1)
numberOfLikes.text = [NSString stringWithFormat:@"%lu like", likesCount];
else
numberOfLikes.text = [NSString stringWithFormat:@"%lu likes", likesCount];
CGSize stringsize = [numberOfLikes.text sizeWithFont:[UIFont systemFontOfSize:14]];
numberOfLikes.frame = CGRectMake(10, 22, stringsize.width, 20);
numberOfLikes.backgroundColor = [UIColor clearColor];
[shareView addSubview:numberOfLikes];
// Display a UILabel of number of comments
if (commentsCount == 1)
numberOfComments.text = [NSString stringWithFormat:@" / %lu comment", commentsCount];
else
numberOfComments.text = [NSString stringWithFormat:@" / %lu comments", commentsCount];
numberOfComments.frame = CGRectMake(numberOfLikes.frame.size.width + 10, 22, 100, 20);
numberOfComments.backgroundColor = [UIColor clearColor];
[shareView addSubview:numberOfComments];
viewEntry.frame = CGRectMake(self.view.frame.size.width - 95, 12, 100, 40);
[viewEntry addTarget:self
action:@selector(viewPublicEntry)
forControlEvents:UIControlEventTouchUpInside];
[shareView addSubview:viewEntry];
}
那里没有任何东西(至少我认为没有)会导致这些奇怪的动画。