I’ve got a UIScrollView with multiple pages, each containing a UITableViewController (similar to the Reminders-App).
Clicking a cell in each of these UITableViewControllers cause a DetailViewController to be pushed.
However, when the DetailViewController gets popped, it immediately disappears behind the UIScrollView, instead of sliding away smoothly. I can see the next page of the UIScrollView sliding away, but when the DetailViewController is pushed from the last page, the transition looks fine because there is no content on the UIScrollView that could overlap the dismissed DetailViewController.
Edit
This is how I create the view controller hierarchy (simplified):
ScheduleViewController.m:
- (void) viewDidLoad {
// ...
for (int i = 0; i < 3; ++i) {
MyTableViewController *myTableViewController = [[MyTableViewController alloc] initWithNibName:@"MyTableView" bundle:nil];
[self.scrollView addSubview:myTableViewController];
[self addChildViewController:myTableViewController];
[myTableViewController didMoveToParentViewController:self];
}
And here is
tableView:didSelectCellAtIndexPath: in MyTableViewController:
(void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// ...
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
DetailViewController* detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
}
}
What could I be doing wrong here? Are there any workarounds to this behavior?
The superview for your
UIScrollViewneeds to haveclipsToBoundsset to TRUE (the option is calledClip Subviewsin the interface builder, if you creating your view that way.) As you noticed, it appears that theUIScrollViewis probably running off its superview, since it is so much larger, and that is causing your animation to look bad. Clipping it will keep that from happening.