In my application, I have a table view. When the user clicks the button, UIView overlays part of this table view. It is essentially a partial modal. This kind of table is intentionally still scrolling while this modal is active. To allow the user to scroll the bottom of the table view, I change the contentInset and scrollIndicatorInsets to adjust the smaller area above the modal. When the modal value is removed, I reset those insertion values.
The problem is that when the user scrolls to the bottom of the newly configured insert, and then rejects the modal mode, the table view jumps sharply to the new scroll position, because the insert instantly changes. I would like to animate it so that the transition occurs, but the beginAnimation / commitAnimations methods do not affect it for any reason.
Edit: More information. I found a conflict. When presenting a modality, I also hide the navigation bar. The navigation bar initially enlivens the table up and down as it is displayed and hidden. When I stop animating the navigation bar, the insert animation works fine. Does anyone know what I can do to get around this conflict? Do I have to wait for the navigation bar animation to complete before setting the insert? If so, how to do it?
Any help is much appreciated!
The corresponding code from the table view controller is here:
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modalOpened) name:@"ModalStartedOpening" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modalDismissed) name:@"ModalStartedClosing" object:nil];
[super viewDidLoad];
}
- (void)modalOpened {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 201, 0);
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 201, 0);
[UIView commitAnimations];
}
- (void)modalDismissed {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
self.tableView.scrollIndicatorInsets = UIEdgeInsetsMake(0, 0, 0, 0);
[UIView commitAnimations];
}