2010-11-03 152 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