久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何以編程方式強制停止 UIScrollView 中的滾動?

How can I programmatically force-stop scrolling in a UIScrollView?(如何以編程方式強制停止 UIScrollView 中的滾動?)
本文介紹了如何以編程方式強制停止 UIScrollView 中的滾動?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

注意:給出的答案這里不適合我.

Note: The answer given here doesn't work for me.

我有一個 UIScrollView(不是表格視圖,只是一個自定義的東西),當用戶執行某些操作時,我想終止視圖內的任何滾動(拖動或減速).我試過做例如這個:

I have a UIScrollView (not a table view, just a custom thing), and when the user takes certain actions, I want to kill any scrolling (dragging or deceleration) inside the view. I've tried doing e.g. this:

[scrollView scrollRectToVisible:CGRectInset([scrollView bounds], 10, 10) animated:NO];

理論上,給定一個已知可見的矩形,滾動將停止在它所在的位置,但事實證明這沒有任何效果 - 顯然滾動視圖看到給定的矩形在界限并且不采取任何行動.我可以讓滾動停止,如果我給出一個絕對當前可見邊界之外的矩形,但在視圖的 contentSize 之內.這似乎按預期停止了視圖......但也導致它跳轉到其他位置.我可能可以在邊緣進行一些操作以使其正常工作,但是有沒有人知道一種干凈的方法來停止正在執行它的滾動視圖?

on the theory that, given a rect that's already known visible, the scrolling will just stop where it is, but it turns out that this doesn't have any effect-- apparently the scroll view sees that the given rect is in bounds and takes no action. I can get the scroll to stop, if I give a rect that is definitely outside the currently-visible bounds, but inside the contentSize of the view. This seems to halt the view as expected... but also causes it to jump to some other location. I could probably do a little playing around at the margins to get this to work reasonably OK, but does anyone know of a clean way to halt a scroll view that's doing its thing?

謝謝.

推薦答案

我玩了一下你原來的解決方案,這似乎工作得很好.我認為您幾乎擁有它,但是您只是抵消了您使用過多的矩形,而忘記了您可以將矩形直接滾動回原始矩形.

I played with your original solution a bit, and this seems to work just fine. I think you almost had it, but you were just offsetting the rect that you used too much, and forgot that you could just scroll the rect straight back to the original rect.

任何滾動動作的通用解決方案是這樣的:

The generalized solution for any scrolling action is this:

- (void)killScroll 
{
    CGPoint offset = scrollView.contentOffset;
    offset.x -= 1.0;
    offset.y -= 1.0;
    [scrollView setContentOffset:offset animated:NO];
    offset.x += 1.0;
    offset.y += 1.0;
    [scrollView setContentOffset:offset animated:NO];
}

從 iOS 4.3(可能更早)開始,這似乎也可以工作

As of iOS 4.3 (and possibly earlier) this also appears to work

- (void)killScroll 
{
    CGPoint offset = scrollView.contentOffset;
    [scrollView setContentOffset:offset animated:NO];
}

這篇關于如何以編程方式強制停止 UIScrollView 中的滾動?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
主站蜘蛛池模板: 国产激情在线 | 伊人免费视频二 | 欧美一区精品 | 成人精品久久 | 国产剧情一区二区三区 | 日本精品视频 | 欧美精品乱码久久久久久按摩 | 国产精品国产成人国产三级 | 日韩精品成人一区二区三区视频 | 99精品免费久久久久久日本 | 久久一区精品 | 亚洲精品456 | 99re在线视频精品 | 国精产品一品二品国精在线观看 | 亚洲精品久久久蜜桃 | 91xxx在线观看 | 亚洲欧美一区二区三区在线 | 日本又色又爽又黄又高潮 | 精品国产欧美一区二区 | 亚洲在线一区二区 | 亚洲国产成人av好男人在线观看 | 日韩毛片播放 | 夜夜精品浪潮av一区二区三区 | 综合久久色 | 国产男人的天堂 | 国产91av视频在线观看 | 中文字幕在线观看一区 | 国产成人99久久亚洲综合精品 | 国产电影一区二区 | 日韩精品一区二区三区在线播放 | 亚洲国产一区二区三区 | 日日天天| 亚洲一区 中文字幕 | 一级黄色录像毛片 | 99re6在线 | 久久久久国产精品一区 | 麻豆av电影网 | 日本在线观看网址 | 亚洲一区二区三区四区五区中文 | 欧美成人性生活 | 欧美国产一区二区 |