2012-02-10 8 views
0

すべてのセルに回転ボタンを備えたテーブルを作成する必要があります。ここでuitableviewcellの回転ボタン

は私のCustomCellクラスのアニメーション方法は

- (void)animateButton { 
__block CustomCell *block_button = self; 
void (^animationBlock)(void) = ^(void) { 
block_button.downloadBackButton.transform = 
    CGAffineTransformMakeRotation(M_PI * 2/3); 
}; 

[UIView animateWithDuration:3.0 
         delay:0.0 
        options:UIViewAnimationOptionRepeat|UIViewAnimationOptionCurveLinear 
       animations:animationBlock 
       completion:nil];} 

そして、私のCustomTableViewController cellForRowAtIndexPathです:メソッド:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
static NSString *CellIdentifier = @"cell"; 

FAMasterTableCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil]; 
    cell = (CustomCell *) [nib objectAtIndex:0]; 
} 
    [cell animateButton]; 
return cell; 

}

問題は、テーブルビューは、iPodのぎくしゃくしていることですが、 iPhone 4で正常に実行されます。

提案がありますか?

答えて

0

毎回新しいアニメーションを追加するのではなく、既にセルに関連付けられているアニメーションを試しましたか?

FAMasterTableCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellIdentifier owner:self options:nil]; 
    cell = (CustomCell *) [nib objectAtIndex:0]; 
    [cell animateButton]; 
} 
return cell; 

また、UIViewアニメーションを使用する代わりにCAAnimationsの使用を検討することもできます。ビューの代わりにレイヤーをアニメートするとパフォーマンスが向上すると思います。

+1

UIViewアニメーションは、直接のCABasicAnimationsよりもはるかに遅くすべきではありません。 UIViewsはCALayersの周りの軽量ラッパーに過ぎず、ベンチマークでは最も古いiOSハードウェア上でさえも、1対のアニメーションの性能差はごくわずかです。 –

+0

非常に良い情報、私は彼らが軽量ラッパーであることを認識していませんでした。 –

+0

はい、Mac上のNSViewsのようなものではありません。たくさんの手荷物があります。 iPhone SDKのベータ版で行った最初のことの1つは、UIViewのパフォーマンスを見ていて、かなり感銘を受けました。私は生のCALayersでいくつかのことをやっていますが、主にMac/iOSクロスプラットフォームの表示コード(Core Plotのようなもの)です。 UIKitはCore Animationを基盤の1つとして明確に構築されました。 –

関連する問題