0

我正在努力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];

参考页

谢谢..

4

1 回答 1

1

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

如果您尝试跨大量 IOS 并尝试使用“不推荐使用”的方法,则会有很多 GUI 错误代码。顺便说一句,您的代码是正确的。

如果你不使用4.0之前的IOS,请改用

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 相关。这让我非常紧张。:)

于 2013-03-05T08:49:12.883 回答