EDIT: I have Found the answer to my own question. Please look at the bottom of my post.
I am having an animation issue trying to push a UIViewController
in didSelectRowAtIndexPath
on a UITableView
programmatically. When I run this code in iOS 6 it works fine. In iOS 7 the animation is messed up (it animates to the left about 20% of the screen then disappears). If I do this in storyboard the animation is fine. Am I missing something or is there a way around this without using storyboard?
// This is a cut down example.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = [[UIViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
}
This is what it looks like right before the tableView disappears. I understand why it does this. Its because the new view being pushed should animate sliding in over it as it does when using storyboard. For some reason it does not work programmatically.
EDIT: This is all I missed For some reason you have to set a backgroundColor.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = [[UIViewController alloc] init];
[viewController.view setBackgroundColor:[UIColor orangeColor]];
[self.navigationController pushViewController:viewController animated:YES];
}
This is the default "parallax" behavior triggered by the pushViewController:animated:
method in iOS7.
Having little experience with storyboards
I suspect that their segue
s are different from UINavigationController
push/pop animations.
You can override the default push/pop by building custom animated or custom interactive transitions.
Or you could use the UIViewController
method:
transitionFromViewController:toViewController:duration:options:animations:completion:
to customize this behavior. Hope this helps and hope I've understood your question...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With