在我的应用程序中,我有一个表格视图 . 当用户单击按钮时,UIView将覆盖该表视图的一部分 . 它本质上是一种部分模态 . 当该模态处于活动状态时,该表视图有意仍可滚动 . 为了允许用户滚动到表视图的底部,我更改了contentInset和scrollIndicatorInsets值以调整模态上方的较小区域 . 当模态被带走时,我重置那些插入值 .
问题是当用户滚动到新调整的插图的底部然后解除模态时,表视图突然跳转到新的滚动位置,因为插入瞬间改变 . 我想为它设置动画以便进行转换,但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];
}
1 回答
我发现了一个修复,但它并不理想 . 我等待插入完成动画后显示导航栏 . 如果可能并发动画,我仍然很好奇 . 另外我想知道是否可以反过来 . (在导航栏完成动画制作后调用插入动画)
这是我修复的代码:
这是在表视图控制器中:
然后在导航控制器中: