Reputation: 1993
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?
Upvotes: 2
Views: 873
Reputation: 1176
The superview for your UIScrollView
needs to have clipsToBounds
set to TRUE (the option is called Clip Subviews
in the interface builder, if you creating your view that way.) As you noticed, it appears that the UIScrollView
is 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.
Upvotes: 6