вращающаяся кнопка в uitableviewcell - PullRequest
0 голосов
/ 10 февраля 2012

Мне нужно создать таблицу с вращающейся кнопкой в ​​каждой ячейке.

Вот мой метод анимации класса 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 4s работает нормально.

Есть предложения?

1 Ответ

0 голосов
/ 10 февраля 2012

Вы пытались использовать анимацию, уже связанную с ячейкой, вместо добавления новой анимации каждый раз?

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;

Возможно, вы захотите использовать CAAnimations вместо анимации UIView. Я считаю, что анимация слоя вместо вида повысила бы производительность.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...