Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 217
Claus Avatar asked Dec 27 '22 09:12

Claus


2 Answers

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*/
                  }];
like image 114
Rakesh Avatar answered Dec 29 '22 06:12

Rakesh


I think the main problem is, that views can have max one superview. Which means a view can not be in two places in the same time. I would try capture the view as image and add it on its superview just before animation and remove the real tableview from its superview. And then you can animate between two different views (image view and table view). In completion block just remove the image view.

How to capture the view :How to capture current view screenshot and reuse in code? (iPhone SDK)

like image 40
Mert Avatar answered Dec 29 '22 05:12

Mert