2
我希望UIScrollView始終回滾到特定點。 我通過寫作來實現它:UIScrollView和targetContentOffset無法正常工作
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
(*targetContentOffset).x = 0.0f;
}
它的工作原理有一個例外精緻漂亮。 當我滾動得足夠遠併到達視圖的末端(然後開始彈跳)並向上拉動手指時,視圖只是在減速稍微後退的情況下平滑滾動,然後停止然後跳轉(無動畫),在此處設置它。 只要我不滾動到滾動視圖的結尾,它就不會發生。
下面是如何初始化的UIScrollView
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 284, frame.size.height)];
scrollView.backgroundColor = [UIColor clearColor];
scrollView.delegate = self;
[scrollView setContentSize:CGSizeMake(285,frame.size.height)];
[self addSubview:scrollView];
UIEdgeInsets inset = scrollView.contentInset;
inset.left = 60;
inset.right = 60;
[scrollView setContentInset:inset];
也許msmialko希望視圖以正常的彈跳效果達到新的targetContentOffset – 2014-07-10 12:00:19