我在SingleView上有UITableView
。表視圖有約束左0,右0,底部0,頂部520.我需要更改頂部520到0滾動向上,當滾動底部返回520.如何可以做到這一點。 如何從滾動的改變NSLayoutConstraint
-如何在滾動時創建NSLayoutConstraint UITableView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
我試圖實現如此,但未能
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if (scrollView.tag == 1){
if (scrollView.contentOffset.y < pointNow.y) {
self.heightLogTabTableView.constant = 0;
[UIView animateWithDuration:0.5f animations:^{
[self.view layoutIfNeeded];
}];
}else if (scrollView.contentOffset.y > pointNow.y) {
self.heightLogTabTableView.constant = 520;
[UIView animateWithDuration:0.5f animations:^{
[self.view layoutIfNeeded];
}];
}
}
}
創建TopSpace約束和變革的出口它的常量值在scrollView委託,如你所願。 –
相反,跟蹤滾動與indexPath你'willDisplayCell'或'CellForRowAtIndexPath'代表和執行基於行或部分 – NSNoob
@NSNoob UITableView的適當行動繼承的UIScrollView – iSashok