簡體   English   中英

在UITableViewCell中旋轉UIImageView-iPhone SDK

[英]Rotate UIImageView in UITableViewCell - iPhone SDK

我的uitableview的uittableviewcell中有一個uiimageview。 我要完成的工作是使用計時器旋轉每個單元格的所有uiimageviews。 我知道nstimer和旋轉概念是如何進行的,但我不知道如何在UITableView中旋轉EACH單元格中的所有圖像。 有沒有辦法訪問所有uitableviewcell的這些屬性?

希望這不會令人困惑,如果它在這里是一個簡單的例子:例如我在我的uitableview中有5個單元格。 由於我的單元格是按慣例制作的,並且具有自己的類,因此5個單元格中的每個單元格都有uiimageview。 我將如何旋轉所有5個uiimageviews?

感謝你的幫助,

凱文

在您的計時器回調函數中,您想要執行以下操作。

NSArray* cellArray = [yourTableView visibleCells];
for (UITableViewCell* cell in cellArray)
{
  // do your cell by cell rotation here
}

為此,當您為無限動畫創建單元格時,可以使用以下代碼。 請記住,如果要緩存單元格,則只需要在創建單元格時執行此操作,而不是在緩存單元格上執行此操作。

[UIView beginAnimations:@"looping animation" context:nil];
[UIView setAnimationRepeatCount:0];     // 0 is infinite
[UIView setAnimationDuration:3];
// other animation options here if you'd like, and the duration can be anything, not just 3.

[UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionRepeat animations: ^{
// do your rotation stuff on your image, in this block, for the cell you will be returning.

} completion:nil];

[UIView commitAnimations];

使用動畫計時器不是最好的方法。

如果您堅持,我建議您簡單地枚舉表格視圖中每個刻度的可見單元格(使用visibleCells tableview方法),並對每個單元格執行旋轉操作。

如何控制動畫流的UIView方法呢? 您可以重復旋轉的動畫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM