1

UITableView が既に配置されているアニメーションを試していますが、各 UITableViewCells のサブビュー (セルのコンテンツ ビューを含む) がウィンドウの境界の外にあります。画面外です。ビューが読み込まれると、フレームの右端の x 値が UITableView の右端の x 値に触れるまで、セルが左から右に 1 つずつアニメーション化されます。

アニメーションは、最初のセルが離陸すると、最初のセルがアニメーションで終了する前に 2 番目のセルが離陸するようなものです。同様に、2 番目のセルのアニメーションが終了する前に、3 番目のセルが離陸します。ただし、これを達成することはできず、すべての行が一緒にアニメーション化されます。

-(void)animateStatusViewCells:(SupportTableViewCell *)cell
{
__block CGPoint center;
[UIView animateWithDuration:0.55 delay:0.55 options:UIViewAnimationOptionCurveEaseIn animations:^{
    center = cell.statusView.center;
    center.x += (cell.frame.size.width - 20);
    cell.statusView.center = center;
}completion:^(BOOL success){
    NSLog(@"Translation successful!!!");
    double delayInSeconds = 2.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        //[self animateStatusViewCells:cell];
    });
}];
}


 -(void)animateSupportTableView:(UITableView *)myTableView
 {
   NSMutableArray *cells = [[NSMutableArray alloc] init];
   NSInteger count = [myTableView numberOfRowsInSection:0];

 for (int i = 0; i < count; i++) {
    [cells addObject:[myTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]];
}

for (SupportTableViewCell *cell in cells) {

    [self animateStatusViewCells:cell];
   }

}

-(void)viewDidAppear:(BOOL)animated{
   [super viewDidAppear:animated];
   [self animateSupportTableView:_statusTableView];
 }

カスタム UITableViewCell の initWithStyle メソッドは次のとおりです。

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
 {
 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
 if (self) {
    // Initialization code
    _statusView = [[UIView alloc] initWithFrame:self.frame];
    self.contentView.backgroundColor = [UIColor greenColor];
    self.contentView.alpha = 0.7;
    CGPoint cellCenter = self.center;
    cellCenter.x = self.center.x -  (self.frame.size.width - 20);
    _statusView.center = cellCenter;

    [self addSubview:_statusView];
    [_statusView addSubview:self.contentView];
 }
 return self;

}

4

3 に答える 3

4

アニメーションごとに異なる遅延値を使用する必要があります。.55 の一定の遅延を使用する代わりに、セル番号を animate メソッドに渡し、次のようなものを使用します。

CGFloat delay = .55 + cellNumber * cellDelay;
[UIView animateWithDuration: 0.55 delay: delay options:UIViewAnimationOptionCurveEaseIn animations:
^{
  //animation code
}
];
于 2013-04-12T19:14:33.673 に答える
2

その価値のために、これはクリーンなソリューションです:

func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell,     forRowAtIndexPath indexPath: NSIndexPath) {
    let trans = CATransform3DMakeTranslation(-cell.frame.size.width, 0.0, 0.0)
    cell.layer.transform = trans

    UIView.beginAnimations("Move", context: nil)
    UIView.setAnimationDuration(0.3)
    UIView.setAnimationDelay(0.1 * Double(indexPath.row))
    cell.layer.transform = CATransform3DIdentity
    UIView.commitAnimations()
}
于 2015-11-12T16:52:25.440 に答える