I am doing an animation, so when you click a button MyAccount from the first screen it will navigate you to Account View
- (void)pushToAccount
{
AccountViewController *controller = [[AccountViewController alloc] initWithNibName:@"AccountViewController" bundle:nil];
//[self.navigationController pushViewController:controller animated:NO];
[UIView beginAnimations: @"Showinfo"context: nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.view addSubview:controller.view];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:NO];
[UIView commitAnimations];
}
However, whenever i click on the Account View Controller ( contains some buttons and images view in it ), my program is crashing at it show EXC_BAD_ACCESS at main class
Please advice me on this issue…
Your view controller is trying to animate a transition by adding another view controller’s view as a subview of your current view. That’s problematic on a whole bunch of dimensions. Notably, you’re not doing anything with the new view controller itself … if this was an ARC project, it will get released on you.
If you just want to transition from one view controller to another, you should generally either do a standard
pushViewController:animated:orpresentModalViewController:animated:. It looks like you used to do the former. Why did you replace it with the current code?If you can tell us what you were trying to do, why you’re not using the standard transitions, perhaps we can help you further.
Update:
If you don’t like the default animation, but rather want some custom animation to your transition, you can do something like:
Update 2:
And, anticipating the logical follow-up question, how do you animate the dismissal of the new view controller, you might, for example have a “done” button that invokes a method like the following: