本文介紹了停用 UIScrollView 減速的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
有沒有辦法取消 UIScrollView 的減速?
Is there a way to deactivate the decelerating of a UIScrollView?
我想允許用戶滾動畫布,但我不希望用戶抬起手指后畫布繼續滾動.
I want to allow the user to scroll the canvas, but I don't want that the canvas continues scrolling after the user lifted the finger.
推薦答案
這可以通過利用 UIScrollView
委托方法 scrollViewWillBeginDecelerating
自動設置內容偏移量來完成當前屏幕位置.
This can be done by utilizing the UIScrollView
delegate method scrollViewWillBeginDecelerating
to automatically set the content offset to the current screen position.
實施:
- 如果您還沒有這樣做,請為您的
UIScrollView
對象分配一個委托. 在您的委托的
.m
實現文件中,添加以下代碼行:
- Assign a delegate to your
UIScrollView
object if you have not already done so. In your delegate's
.m
implementation file, add the following lines of code:
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
[scrollView setContentOffset:scrollView.contentOffset animated:YES];
}
瞧!不再自動滾動.
這篇關于停用 UIScrollView 減速的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!