无处不在的动画来自无处

时间:2013-02-28 17:00:46

标签: ios animation uiview addsubview

在我的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];
}

那里没有任何东西(至少我认为没有)会导致这些奇怪的动画。

1 个答案:

答案 0 :(得分:1)

我有这个问题。原因最终是在没有调用提交的情况下调用开始动画。我以某种方式称[UIView beginAnimations:Nil context:nil]两次。