4

Hi first of all i know its really a dumb question.I don't have any experience in UIAnimation so I stucked on it from long time. I am making a application in which a viewcontroller contains lot of views. No matter if they are in tableview, but for example if i clicked the view which is in the 20th position.So i want after clicking, the selected view automatically moves with ANIMATION to the first place and the view which was in the first place it shift to second position by ANIMATION.I am trying to something like that. But animation is fast and not beautiful.I want simple way to do it. Thanks in Advance

    NSArray *selectedCellIndices = [self.gView indicesOfSelectedCells];

    NSMutableArray *numbersToDelete = [NSMutableArray array];
    for (NSNumber *indexToDelete in selectedCellIndices)
    [numbersToDelete addObject:[self.numbers objectAtIndex:[indexToDelete integerValue]]];

    //remove the entries from the data source
    [self.numbers removeObjectsInArray:numbersToDelete];
    //animate the cells leaving the gview
    [self.gView deleteCellsAtIndices:selectedCellIndices animated:YES];
    NSNumber *newNumber = [numbersToDelete objectAtIndex:0];
    [self.numbers insertObject:newNumber atIndex:0];
    [self.gView insertCellAtIndex:0 animated:YES];

For animation i use something like that

[UIView animateWithDuration:0.30f delay:i*0.03f options:UIViewAnimationOptionCurveEaseInOut animations:^{
                    CGRect frame = cell.frame;
                    frame.origin = newOrigin;

                    //cap how far it can move up so it doesn't just shoot off so quickly that it becomes invisible
    if (CGRectGetMaxY(cell.frame) - (newOrigin.y+CGRectGetHeight(self.bounds)) > CGRectGetHeight(self.bounds))
                    frame.origin.y = CGRectGetMinY(cell.frame) - (CGRectGetHeight(self.bounds)+CGRectGetHeight(cell.frame));

                    cell.frame = frame;
        } completion:^(BOOL finished) {
    if (index != finalCellIndex)
                    return;

                    completionBlock();
}];
AG.29
  • 230
  • 1
  • 20

0 Answers0