pushViewController without title animation - iphone

I push Viewcontroller using this code:
if (! self.infoViewController) {
self.infoViewController = [[InfoViewController alloc] initWithNibName:#"InfoViewController" bundle:nil];
}
[UIView animateWithDuration:0.7f
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.navigationController pushViewController:self.infoViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
Is it possible to disable navigationBar title animation? It's slide from left during animation.

Push your ViewController without animation like this:
if (! self.infoViewController) {
self.infoViewController = [[InfoViewController alloc] initWithNibName:#"InfoViewController" bundle:nil];
}
[self.navigationController pushViewController:self.infoViewController animated:NO];
this will not animate ur pushing title. I hope this will helps u.

I'm sorry. Here is the answer:
[UIView animateWithDuration:0.7f
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
[self.navigationController pushViewController:self.infoViewController animated:NO];

Related

ViewController transition

I have code:
ListViewController * listViewController = [[ListViewController alloc] initWithNibName:#"ListViewController" bundle:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[self viewWillDisappear:YES];
[listViewController viewWillAppear:YES];
self.view.hidden = YES;
listViewController.view.hidden = NO;
[self viewDidDisappear:YES];
[listViewController viewDidAppear:YES];
[UIView commitAnimations];
But it does not works, and listViewController does not displayed( Please, somebody can tell me the solution of this problem?
Try something like:
UIViewAnimationOptions ops = UIViewAnimationOptionTransitionFlipFromRight;
NSArray *temp = [[NSBundle mainBundle] loadNibNamed:#"NameOfNib" owner:self options:nil];
UIView* newView = [[temp objectAtIndex:0] view];
[UIView transitionFromView:self.view toView:newView duration:1.5 options:ops completion:nil];
self.view = newView; //Lets you control the new view from the current controller (you might want to save a reference to the old one if you need to change back)
As meronix said, non-block based animation is discouraged by Apple for the newer iOS versions. The above method is the "approved" way to do it.
Just so you know, the viewWillAppear, viewDidDisappear, and similar methods aren't methods that YOU call to make the view do things. They're called automatically when these things happen.
Your code had a few misunderstandings; I've commented on them below
//This looks fine (depending on what is in the nib)
ListViewController * listViewController = [[ListViewController alloc] initWithNibName:#"ListViewController" bundle:nil];
//Normally I use these to move things around, not change the view
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[self viewWillDisappear:YES]; //These two methods aren't things that you call
[listViewController viewWillAppear:YES];
self.view.hidden = YES; //If you're flipping or otherwise moving a view out of
listViewController.view.hidden = NO; //sight then you don't need to hide/unhide views
[self viewDidDisappear:YES]; //Same as above, you don't call these
[listViewController viewDidAppear:YES];
[UIView commitAnimations];
Remove unnecessary code and just write this ...
ListViewController * listViewController = [[ListViewController alloc] initWithNibName:#"ListViewController" bundle:nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];
[self.view addSubview:listViewController.view];
[UIView commitAnimations];
it cannot work!
you just create and allocate a UIViewController, but never push it on any stacks, or add its view to a visible view.
when you set listViewController.view.hidden to no, you are not magically showing it on screen: you need to add its view to a view (or window) which is already on screen...
ps beginAnimation is deprecated: use blocks animation instead...

Why do I see jerky animation when using this UIView animation block?

I have a a tab bar that is made in the application delegate. By calling an action form a button click from one of the views loaded from the tab bar, I open the help screen but there is a jerking motion after loading.
forgive me for speaking informally..I have been picking my brain for the past few hours trying to figure this out..
-(void)flipToHelp {
HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:#"HelpView" bundle:nil];
[self setHelpViewController:helpVariable];
[UIView beginAnimations:#"flipview" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:_window cache:YES];
[_window removeFromSuperview];
[helpVariable release];
self.window.rootViewController = self.HelpViewController;
[UIView commitAnimations];
}
Just to reiterate from the comment thread, you shouldn't be removing the window from its superview (it doesn't technically have a superview, so it's probably causing problems). And setting the window's rootViewController property should swap out the view hierarchies, Apparently the jerkiness comes from changing the window's rootViewController property, so maybe the solution is to avoid using that property. Here's what I think should be enough to accomplish this:
-(void)flipToHelp {
HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:#"HelpView" bundle:nil];
[UIView beginAnimations:#"flipview" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:_window cache:YES];
[self.tabBarController removeFromSuperview];
[_window addSubview:helpVariable];
[UIView commitAnimations];
}
-(void)flipToHelp {
HelpViewController *helpVariable = [[HelpViewController alloc] initWithNibName:#"HelpView" bundle:nil];
[self setHelpViewController:helpVariable];
[helpVariable release];
[UIView beginAnimations:#"flipview" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self.window
cache:YES];
self.window.rootViewController = self.HelpViewController;
[UIView commitAnimations];
}
How about this code? Does it still have a jerky animation?

How do i do a flip animation on pop view controller?

I have a flip animation which goes like this:
Picker *picker = [[Picker alloc] init];
[self.navigationController pushViewController:picker animated:NO];
[UIView animateWithDuration:0.5
animations:^{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}
completion:^(BOOL finished){
}];
[picker release];
This works perfectly. But when i want to do popViewController to get back, like this:
[self.navigationController popViewControllerAnimated:NO];
[UIView animateWithDuration:0.5
animations:^{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}
completion:^(BOOL finished){
}];
But this doesn't work, just goes back to the view without animating.
Have you tried calling popViewControllerAnimated after the animation ends?
Put the popViewController call inside your completion block, so it animates first and then pops.

Custom Transition Between Navigation Controllers

I want to have a custom transition between two navigation controllers. Let's call the first one sourceController and the other one detailNavController.
Here's my code:
NewEntryViewController *viewController = [[NewEntryViewController alloc]
initWithStyle:UITableViewStyleGrouped];
viewController.parentController = self;
UINavigationController *detailNavController = [[UINavigationController alloc]
initWithRootViewController:viewController];
[UIView beginAnimations:nil context:NULL];
[self.navigationController presentModalViewController:detailNavController animated:NO];
[UIView setAnimationDuration:0.4];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:sourceController.view cache:YES];
[UIView commitAnimations];
SourceController was first presented modally, that's why I'm presenting detailNavController modally. The problem with this code is that the animation takes place, but sourceController is still on top of the new detailNavController. What I would like to achieve is to have the animation and then dismiss sourceController and have detailNavController displayed.
I've finally found the solution for this, here's the updated code:
- (void)createNewEntryWithAnimation
{
// before calling this method I dismissed sourceController without animation
NewEntryViewController *viewController = [[NewEntryViewController alloc] initWithStyle:UITableViewStyleGrouped];
viewController.parentController = self;
UINavigationController *detailNavController = [[UINavigationController alloc]
initWithRootViewController:viewController];
[UIView beginAnimations:nil context:NULL];
[self.navigationController presentModalViewController:detailNavController animated:NO];
[UIView setAnimationDuration:0.4];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewController.view.window cache:NO];
[UIView commitAnimations];
}
I had to use cache:NO, otherwise the transition wasn't smooth.

presentModalViewController gives error?

if i run following gives error,current controller is table controller....
SetController *aSecondView = [[SetController alloc] initWithNibName:#"Sets" bundle:nil];
SchedAppDelegate *mainDelegate = (SchedAppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate setSettingsViewController:aSecondView];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:[[self view] superview] cache:YES];
[self.view removeFromSuperview];
[self presentModalViewController:aSecondView animated:NO];
//[aSecondView release];
[UIView commitAnimations];
It appears that mView is a UIViewController and not a UIView.
This is the proper way to apply a custom animation to a modal view controller:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:[self view] cache:YES];
[self presentModalViewController:mView animated:NO];
[UIView commitAnimations];
If mView is a view controller, you can present it with a flip animation by doing the following:
mView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:mView animated:YES];
The modalTransitionStyle property is only available for iPhone OS 3.0 onwards. Hope this helps. :)