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];
}