I have a small problem with UINavigationController animation between two view.
My application build more than two view,
first view contains login information, second view contains root menu, last view contains sample data and so on..
My MainWindow.xib contains a UINavigationController component which is contains all navigation structure.
When my login view loaded, i use this lines of code
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:NO];
}
for hide UINavugationConttoller (I don't need to show to user navigation bar during the login.)
After that when the user execute the login submit button on the login view
i use this code for push the RootmenuView to the UINavigationController's stack.
RootMenuController *rootMenuController = [[RootMenuController alloc] initWithNibName:#"RootMenuController" bundle:0];
[self.navigationController pushViewController:rootMenuController animated:NO];
[rootMenuController release];
It's working very well. And when the Rootmenuview loaded user have to show the navigation bar then i'm showing the UINavigation's tool bar with this code
- (void)viewDidAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
But i don't like the default animation transitions of UINavigationController then i changed above code with below
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:0.50];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:
UIViewAnimationTransitionFlipFromRight
forView:self.navigationController.view cache:YES];
RootMenuController *rootMenuController = [[RootMenuController alloc] initWithNibName:#"RootMenuController" bundle:0];
[self.navigationController pushViewController:rootMenuController animated:NO];
[UIView commitAnimations];
[rootMenuController release];
It's working too but UINavigationController flickering during between two view naimation transition.
I didn't solve this problem.
Any suggestions ?
Thank you
Have you tried [setAnimationTransition:forView:cache:NO]? I got some odd behavior similar to yours when I used to mess around with UIView animations and used caching.
Related
To put it simply, I've built an app which started without a Navigation Controller so everything was controlled through my ViewController. Since adding the Navigation Controller, I added a button to flip to my main Navigation Controller window from my ViewController. However, when I push the button, it reloads the same window with the Navigation Bar now across the top(I hid it in the original view). If I push the same button again, it then loads the proper view. What did I do wrong to cause this loop?
My button's code below
-(IBAction) btnSettings_Clicked: (id) sender {
self.navigationController.navigationBarHidden = FALSE;
[UIView beginAnimations:#"Flip View" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
MyAppDelegate* appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self.navigationController view] cache:YES];
[UIView commitAnimations];
[appDelegate.navigationController popViewControllerAnimated:NO]; }
If this code is in ViewController and, as you say, this controller is not pushed on a navigation controller, then the error is:
[self.navigationController view] ;
because there are no navigation controller for self. You have to replace it with:
[appDelegate.navigationController view] ;
As I asume that is the correct navigation controller to use.
And then, why are you popping the top view controller? If you want to remove self.view, then you only have to do it:
[self.view removeFromSuperview];
I believe it is this line
[self.navigationController view]
You should set the animation to the controller you wish to show and not to the current controller.
I need some help with some basic transition work. I think I don't understand this conceptually.
I load a main view which loads a 'log in screen' in its viewDidLoad.
The 'log in screen' is a custom xib + custom view controller.
It is loaded in the following way:
ISSplashScreenViewController* splashScreenController = [[ISSplashScreenViewController alloc] initWithNibName:#"ISSplashScreen" bundle:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:splashScreenController.view cache:YES];
[UIView setAnimationDuration: 1.5];
[splashScreenController viewWillAppear:YES];
[self.view addSubview:splashScreenController.view];
[splashScreenController viewDidAppear:YES];
[UIView commitAnimations];
All I can see is the status bar animating (and I think this is because it is hidden in the main window but I call for it in the log in screen's viewDidLoad).
The body of the log in screen 'just appears'.
I was wondering if someone could explain why this isn't working and perhaps suggest what i could do to make it work. I think I have to remove the main view from the application's sub views and then load the log in view.
I tried this also, but it doesnt work. The main view just sits there.
[splashScreenController viewWillAppear:YES];
[self.view.superview addSubview:splashScreenController.view];
[self.view.superview bringSubviewToFront:splashScreenController.view];
[self.view removeFromSuperview];
[splashScreenController viewDidAppear:YES];
Any help is much appreciated,
Thanks
Try calling -setAnimationTransition:forView:cache: with self.view rather than the splash-screen controller’s view.
I want to slide a UITableVIew into a view (NOT by pushing the view on top of Navigation Controller) on click of a button and then hide it back by sliding , on clicking of the same button.
I want the tableView to slide inside a present view.
You animate the frame property of the table view to move it off screen or back onto screen.
Here is some sample code that moves a table view off screen and moves another on screen in its place:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kSlideTableDuration];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(tableAnimationDidStop:finished:context:)];
self.tableView1.frame = offScreen;
self.tableView2.frame = onScreen;
[UIView commitAnimations];
You can read about animation blocks like this in the UIView documentation.
Check out the documentation of UINavigationController. To implement you would do something similar to this:
iPhoneCustomViewController *newView = [[iPhoneCustomViewController alloc] initWithNibName:#"iPhoneCustomViewController" bundle:nil];
[self.navigationController pushViewController:newView animated:YES];
[newView release];
Then, when your done with the CustomViewController do:
[self.navigationController popViewControllerAnimated:YES];
You get the nice slide animations for free if you use a UINavigationController. It will take care of sliding views in (push them on the navigation controller stack) and sliding them out (pop them off the navigation controller stack).
I am flipping over to an info view on the backside. I have it flipping, and I have a navigation bar on the other side to get me back home to the original view (which was a problem when I was trying to use a modal).
My problem now is that it only works the first time: I tap the info button, I flip to the backside. I tap the back button and I can flip back no problem.
But, if I tap that info button again, it pushes over to the info view instead of flipping. The flip back is still fine. If I leave the root view and go elsewhere and come back, it flips properly again.
In the method that is invoked when I click the info button:
InfoViewController *controller = [[[InfoViewController alloc] init] autorelease];
[UIView beginAnimations:#"animation" context:nil];
[self.navigationController pushViewController: controller animated:NO];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Thanks for your help!
where you initializing InfoViewController ?
as every time you come on the Root it's getting initialize and working fine...
When you click back it doesn't.... so easy fix will be write this code in viewWillAppear...which gets called every time you visit the view..
Hope this helps..
Here is a bit newer implementation which uses blocks from newer UIView APIs and relies on ARC.
This is how you push new flipping screen:
InfoViewController *controller = [[InfoViewController alloc] init];
[self.navigationController pushViewController:controller animated:NO];
[UIView transitionFromView:self.view
toView:controller.view
duration:0.8f
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished) {
// Add completion stuff here
}];
And here is the snippet for dismissing it:
[self.navigationController popViewControllerAnimated:NO];
[UIView transitionFromView:controller.view
toView:self.view duration:0.8f
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
// Add completion stuff here
}];
i have coded following in appDelegeate .m file .but i cant run presentModalViewController method.if i run [self.window addSubview:mview] ,it does not show the result..?any help
to go from one controller to another controller?here mtController is Navigationcontroller.
- (void)flip
{
MViewController *mview = [[MViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:window
cache:YES];
[mtController.view removeFromSuperview];
[self.window addSubview:mview];
// [self presentModalViewController:mailView animated:YES];
[UIView commitAnimations];
[mailView release]
}
If you want to add a NavigationController to a window you are supposed to call
[self.window addSubview:mview.view];
And if you want to go from one view in a NavigationController to another view, the correct thing to do would be to push the new ViewController.
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
In your code sample you create an object called mview, but then below in the presentModalViewController you reference mailView (and in the release). Is that a mistake?
After you add the mview.view to the window, is it the only view on the stack? If not, you might need to bring it to the front. Also, assuming the release statement at the bottom was meant to be [mview release] you're going to have another problem if you don't save/retain that view controller. I don't believe adding it to the window subviews retains it.