2010-11-03 108 views

回答

2

是的,你当然可以使用UIView动画来移动元素。

此外,常见的技术是隐藏接口的

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 

部分重绘,并显示它作为

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 

这里部是一个例子:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.3f]; 
    self.myTable.hidden = YES; 
    ... 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
    [UIView commitAnimations]; 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    [self redrawInterface]; 
    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:0.3f]; 
    self.myTable.hidden = NO; 
    ... 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
    [UIView commitAnimations]; 
} 
+0

稍微扩展一下;如果您没有设置animationDuration或animationCurve,那么您将获得用于旋转动画的相同默认值。它不只是隐藏的,你可以改变,它是任何动画的属性(使用苹果术语,帮助搜索)。这些包括框架/边界和中心以及变换属性。您可以使用transform属性进行任何类型的翻译,缩放或旋转。但要小心; transform属性会挂钩到合成器(即视图的缓冲版本),而不是执行任何CPU上的工作。 – Tommy 2010-11-03 21:53:46