在我的應用程序,我有一個表視圖。當用戶點擊一個按鈕時,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];
}