Search code examples
iosuitableviewuiviewtransitionuiviewanimationtransition

UIView transitioning to the same view


I have a UITableView controller displaying static tableview. I have to update the project providing a secondary mode where this tableview is supposed to flip and to show different data. My approach would be to put all the static cells of both modes in one big static tableview, to perform a flip and to hide the cell which are not required at that specific moment. The flip should be performed only on the tableviewcontrollerview,so not affecting the navigationbar or the main tabbar. The code I've been trying to use so far for realising this simple magic trick is:

// Transition using a page flip.
    [UIView transitionFromView:self.tableview
                        toView:self.tableview
                      duration:0.7
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    completion:^(BOOL finished) {
                        if (finished) {
                           /* HIDE NOT REQUIRED CELL */

                        }
                }];

Unfortunately the result is a black screen. Any idea how to fix it?


Solution

  • Try using the below code instead:

    [UIView transitionWithView:self.tableView 
                       duration:0.7
                       options:UIViewAnimationOptionTransitionFlipFromLeft 
                       animations:^{
                              /* any other animation you want */
                      } completion:^(BOOL finished) {
                              /* hide/show the required cells*/
                      }];