views:

858

answers:

2

I have two views: one has just a button (view 1) and the other contains a tableview with a search bar (screen2). When the user clicks that button in view 1, I want view 1 to flip and display screen 2.

View 2 resides inside of the navigational controller with a navigation bar on top.

Below is what I have for now. The transition animation works and flips to the second screen but view 2 is missing the SearchBar and title from NavigationBar. Both are set inside view 2.


[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];

navigationController = [[UINavigationController alloc] init];

bestbuyProducts = [[BestBuyProductsViewController alloc] initWithNibName:@"BestBuyProductsViewController" bundle:nil];  
[navigationController pushViewController:bestbuyProducts animated:NO];
[navigationController.view setFrame: [self.view bounds]];
[bestbuyProducts release];

[self.view addSubview:navigationController.view];

[UIView commitAnimations];

Thank you

A: 

Hi, To start your UINavigationController is not initialise correctly. Use the initWithRootViewController: method like that:

bestbuyProducts = [[BestBuyProductsViewController alloc] initWithNibName:@"BestBuyProductsViewController" bundle:nil];  

// Initialise the navigation view with the bestbuyProducts view controller
navigationController = [[UINavigationController alloc] initWithRootViewController:bestbuyProducts ];

Then try to use modal view transition to make a flip animation, It's easier and more safe to start:

[navigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:navigationController animated:YES];

[navigationController release];
[bestbuyProducts release];
Yannick L.
Yannick, your code brings my screen 2 properly i.e. I can see my searchbar and navigationbar has title, BUT no flip effect...
Igor Kilimnik
Ah yes sorry, I have made a mistake make the setModalTransitionStyle on the bestbuyProducts like that: [bestbuyProducts setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];Sorry again.
Yannick L.
A: 
Igor Kilimnik