在我的应用程序,我有一个表视图。当用户点击一个按钮时,UIView将覆盖该表视图的一部分。它本质上是一种部分模态。该表格视图在故意模式处于活动状态时仍然可以滚动。为了让用户滚动到表格视图的底部,我改变了contentInset和scrollIndicatorInsets值来调整模态上方的较小区域。当模式被拿走时,我重置这些插入值。iPhone:无法动画的contentInset动画导航栏显示/隐藏
问题是,当用户滚动到新调整的插图的底部,然后解散模态时,表视图突然跳到新的滚动位置,因为插入立即改变。我想动画它,所以有一个过渡,但由于某种原因,beginAnimation/commitAnimations方法不会影响它。
编辑:更多信息。我发现了冲突。当呈现模式时,我也隐藏导航栏。导航栏自动将表格视图上下显示并隐藏。当我停止对导航栏进行动画处理时,插图动画可以正常工作。有谁知道我能做些什么来解决这场冲突?在调整插图之前,是否必须等待导航栏动画完成?如果是这样,我该如何挂钩?
任何帮助,非常感谢!
从表视图控制器相关的代码是在这里:
- (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];
}