I'm having a lot of trouble setting a flip transition between storyboards. The app crashes when the method below is called. I'm getting the error message:
[NSPathStore2 setView:]: unrecognized selector sent to instance...
This is my code:
- (void)advanceToNextViewController {
humptyDumptyViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:#"firstStoryVC"];
/*
[self.navigationController pushViewController:controller animated:YES];
*/
[UIView beginAnimations:#"animation" context:nil];
[self.navigationController pushViewController:controller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
}
I'd appreciate any help with this.
Since you are using storyboard. This is more accurate, try this:
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"firstStoryVC"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
But be sure to name your view's identifier "firstStoryVC" otherwise it will crash and wont work.
Then when you want to dimiss the view:
[self dismissModalViewControllerAnimated:YES];
Try this one , it will give you full control over timings and animation.
humptyDumptyViewController *controller = [self.storyboardinstantiateViewControllerWithIdentifier:#"firstStoryVC"];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:controller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Related
I have a button 'filter' on left side on navigation bar. On clicking it I want flip animation with flip delay of 1.5 second while switching to the next view. How to add the code for that?
I am working with this navigation code:
FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self.delegate pushViewController:vc animated:UIViewAnimationTransitionFlipFromLeft];
[vc release];
Now I want a flip delay of 1.5 seconds on view switch by button. I have tried some code but it's not giving me the desired result.
Try this
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:vc animated:YES];
[UIView commitAnimations];
[vc release];
taken from How to do the flip animation between two UIViewControllers while clicking info button?
Other way:
MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[super pushViewController:nextView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
I get this from How to change the Push and Pop animations in a navigation based app
Use this for delay the push animation:
FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self performSelector:#selector(callViewController:) withObject:vc afterDelay:1.5];
-(void)callViewController:(FilterViewController*)vc{
[self.delegate pushViewController:vc animated:UIViewAnimationTransitionFlipFromLeft];
[vc release];
}
I'd like create a custom segue to swap ViewControllers with a curl up animation but I can't find a way, What would be the -(void)perform for this?
I've got this
-(void)perform{
UIViewController *dst = [self destinationViewController];
UIViewController *src = [self sourceViewController];
[UIView beginAnimations:nil context:nil];
//change to set the time
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:src.view cache:YES];
[UIView commitAnimations];
}
But I don't get to change the view, anyway thanks for your help!
Nevermind, I solved it, for the record the only thing I had to do was add a Navigation Controller and then I could use custom segues like:
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
[UIView transitionWithView:src.navigationController.view duration:0.3
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[src.navigationController pushViewController:dst animated:NO];
}
completion:NULL];
}
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.connectionIndicator = [[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
[self.view addSubview:connectionIndicator];
[self.connectionIndicator setCenter:CGPointMake(self.view.frame.size.width/2, 15)];
[connectionIndicator startAnimating];
}
The spinner shows up frozen, and does not start animating.
Edit: Okay I figured out the cause but yet to find a solution.
This view controller is pushed into navigation controller stack through a page curl-up transition:
ServerHandshakeViewController *shvc = [[ServerHandshakeViewController alloc] initWithHost:h];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[self.navigationController pushViewController:shvc animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[shvc release];
Removing the above curl-up transition like below solves the spinner freeze problem.
ServerHandshakeViewController *shvc = [[ServerHandshakeViewController alloc] initWithHost:h];
[self.navigationController pushViewController:shvc animated:NO];
[shvc release];
But then, what if I want to retain my curl-up page transition?
You could try using the block method where you can specify animation options. UIViewAnimationOptionAllowAnimatedContent is the option which should free up the spinner.
[UIView transitionWithView:self.navigationController.view
duration:1.0
options:UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationTransitionCurlUp | UIViewAnimationOptionCurveEaseInOut
animations:^{[self.navigationController pushViewController:shvc animated:NO];}
completion:nil];
-(IBAction)buttonPressed1:(id)sender
{
SignView *tempVC = [[SignView alloc] initWithNibName:#"SignView" bundle:Nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDelay:0.0f];
[UIView setAnimationDuration:0.2f];
[self presentModalViewController:tempVC animated:YES];
[tempVC passDataWithString:button1.titleLabel.text andColor:currentlySelectedColor isNightModeOn:nightMode.on];
[UIView commitAnimations];
}
can anyone help me figure out why this code doesn't work?
This method will call beginAnimations: and commitAnimations, which cannot be nested.
[self presentModalViewController:tempVC animated:YES];
So move it to before beginAnimations: or after commitAnimations.
I am new to Iphone SDK.i am using following code.but the animation happens
from Right to Left when i click this button.i want to do fro botton to Up
- (IBAction)clickedsButton:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:settingsController animated:TRUE];
[UIView commitAnimations];
}
setAnimationTransition supports only Two ...
1)UIViewAnimationTransitionFlipFromLeft
2) UIViewAnimationTransitionFlipFromRight..
any help please? i used following, but it is not working
settingsController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:settingsController animated:YES];
What you're looking for is
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated;
SWIFT 3
self.present(newViewController, animated: true, completion: nil)