展开和折叠动画在ios6中不工作



我正在研究UIView。此视图在单击按钮时展开和折叠。它在iOS<=5上工作,但不能在iOS6上工作。你能更正我的代码或者解释一下吗?

谢谢。我代码:

    CGFloat x= 60,y = 391,w1=210,h1=48;
    [ViewShare setHidden:YES];
    [UIView beginAnimations:@"animationOff" context:NULL]; 
    [UIView setAnimationDuration:0.2f];
    [ViewShare setFrame:CGRectMake(x, y, w1, h1)];
    [UIView commitAnimations];

And Ref Page

谢谢. .

Mani,你应该使用基于块的动画,因为iOS 4.0之后不鼓励使用提交动画。

如果你尝试跨许多IOS,并尝试使用"deprecated"方法,那么会有许多GUI错误代码。顺便说一下,你的代码是正确的。

如果你没有使用IOS 4.0之前的版本,请使用

animateWithDuration:animations:completion:

下面是一个例子:

[UIView animateWithDuration: 0.2f
     animations:^{
    [ViewShare setFrame:CGRectMake(60, 391, 210, 48)];
}
     completion:^(BOOL finished){ 
    // what you want when the animation is done
}];

注意,有时候,你需要根据iOS版本切换行为,它总是与GUI相关。这让我很紧张。:)

最新更新