Present modalViewController in another view - iphone

I've implemented a facebook like slide menu. When I swipe the navigationBar, the "Settings" view will appear underneath.
The problem is when I try to present a modal view from the Settings view. I try to implement a feedback system (MFMailComposeViewController), but if I present it from the Settings view underneath, half of the modal view will be blocked by the overlay view (The rootView controller).
What can I do to fix this problem?
Thanks in advance
masterViewController = [[MatchTable alloc] initWithNibName:#"MatchTable" bundle:nil];
self.navigationController = [[UINavigationController alloc] initWithRootViewController:masterViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
Settings *sideMenuViewController = [[Settings alloc] initWithNibName:#"Settings" bundle:nil];
// make sure to display the navigation controller before calling this
[MFSideMenuManager configureWithNavigationController:self.navigationController sideMenuController:sideMenuViewController];

Well i did it like this to give it a sort of animation effect..You can choose any other effect you like:
[UIView beginAnimations:#"Flip" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:appDelegate.window.rootViewController.view cache:YES];
[appDelegate.window.rootViewController.view addSubview:#"Your View Object"];
[UIView commitAnimations];

Related

can not scroll table up and down after using animation and a navigation bar disappears

My first view contains a button and after pressing a button, i will end up with the second view. what I have done is
FirstViewController.m
- (void)pushToWishList {
SecondViewController *controller = [[SecondViewController alloc] initWithNibName:#"SecondView" bundle:nil ];
[UIView beginAnimations:#"flipping view" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
[self.view addSubview:controller.view];
[UIView commitAnimations];
}
SecondViewController is an UIViewController such that :
SecondViewController.h :
#interface SecondViewController :
UIViewController
SecondViewController.m
self.navigationController.navigationBarHidden = NO;
self.navigationItem.hidesBackButton = NO;
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
What is happening is the top navigation is disppearing and the UITableView in my second view can not be scrolled up and down. My program is crashed whenever I try to do this.
Please advice me on this issue. Any comments are welcomed here.
First off its easier to not addSubview: just use this code to turn your page:
- (IBAction)myCart:(id)sender; {
viewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewController animated:YES];
}
This will allow your tableView to scroll! Also, your method return type is void, if you are using a button to call this method, you need to change the return type to IBAction which works for buttons.

iPhone View Animation

I am trying to switch views, but I want the animation with the view lifts up and its like a piece of paper folding to see what is underneath.
Any tutorials or examples of how to get that view animation, if it is an animation, would be appreciated.
Actually the view that the maps app uses when you hit the button on the corner.
Something like this should work:
MyViewController *myView = [[MyViewController alloc] initWithNibName:#"MyViewController" bundle:nil];
myView.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(dismissModalViewControllerAnimated:)] autorelease];
UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:myView];
navigation.modalTransitionStyle = UIModalTransitionStylePartialCurl;
navigation.delegate = self;
[self presentModalViewController:navigation animated:YES];
The key here is the modalTransitionStyle property needs to be set to UIModalTransitionStylePartialCurl before presenting the modal view.
More info here: UIViewController Class Reference (look for modalPresentationStyle, modalTransitionStyle, presentModalViewController:animated:, and dismissModalViewControllerAnimated:).
There are two basic ways of doing this, the old one which is no longer recommended:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:containerView cache:YES];
[containerView addSubview:subview];
[UIView commitAnimations];
And the new one (It uses blocks which are supported from iOS 4 and on):
[UIView transitionWithView:containerView duration:0.5
options:UIViewAnimationOptionTransitionCurlDown
animations:^ { [containerView addSubview:subview]; }
completion:nil];

animating views half working

I am using the following code to animate a view on to another view. it works but only the navigation bar items are being animated the rest of the view just appears. I have tested on iphone and iphone simulator same problem on both. I would like the whole view to curl in not just the buttons.
loginView = [[loginController alloc] initWithNibName:#"login" bundle:[NSBundle mainBundle]];
UIView *containerView = self.view;
[UIView transitionWithView:containerView
duration:2.0
options:UIViewAnimationOptionTransitionCurlUp
animations:^{ [containerView addSubview:loginView.view]; }
completion:NULL];
}
You speed up the animation duration which is default 3.0 so that it act like that

Flip complete UITabView on the iPhone

I have a TabView based application on the iPhone. On initial loading, I want to flip-animate the screen for showing some settings.
In my AppDelegate, the TabView is added to the window with
[window addSubview:tabBarController.view];
I browsed the web and found this:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:tabBarController.view
cache:YES];
[window addSubview:settingsViewController.view];
[UIView commitAnimations];
But when I test this in the simulator the only change I can see is that the TabMenu floats from right to left.
Can this be solved?
You could present the settings view as a modal view. You can specify the animation to flip from right to left.
[settingsViewController.view setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[tabBarController presentModalViewController:settingsViewController animated:YES];
To return:
[self.parentViewController dismissModalViewControllerAnimated:YES];
Thanks, that worked. But I had to insert a navigationController:
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:settingsViewController];
[navigationController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[tabBarController presentModalViewController:navigationController animated:YES];
[navigationController release];
[settingsViewController release];
But now the next question: How do I get back? :)

How do I use Flip Transition to go from a UIView to a TableViewController with a NavigationController?

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
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];
OK here is the correct version
navigationController = [[UINavigationController alloc] initWithRootViewController:bestbuyProducts];
[bestbuyProducts setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:navigationController animated:YES];