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

如何以編程方式強(qiáng)制停止 UIScrollView 中的滾動?

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

問題描述

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

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

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

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];

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

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?

謝謝.

推薦答案

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

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];
}

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

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

相關(guān)文檔推薦

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(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
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)
主站蜘蛛池模板: 精品久久久久久亚洲国产800 | a视频在线观看 | 成人免费看片 | 亚洲国产精品视频一区 | 日韩国产黄色片 | 精品无码久久久久国产 | 国产欧美在线视频 | 特级特黄特色的免费大片 | 欧美精品成人一区二区三区四区 | 欧美午夜视频 | 国产成人免费网站 | 黄色一级免费观看 | 亚洲一区日韩 | www视频在线观看 | 欧洲精品在线观看 | 欧美在线综合 | 国产欧美一区二区三区在线看 | 午夜精品久久久久久久久久久久久 | 在线天堂免费中文字幕视频 | 中文字幕亚洲视频 | 国产我和子的乱视频网站 | av一区二区三区四区 | 久久久2o19精品 | a欧美 | 男人av在线播放 | 欧美日韩1区2区 | 日本天天操 | www日| 在线电影日韩 | 久久久123| av官网在线 | 精品国产一区二区三区免费 | 一二三四av | 精品视频一区二区三区 | 成人在线影视 | 天天操天天射综合网 | 亚洲毛片 | 男女羞羞视频免费看 | 婷婷在线网站 | 网络毛片| 国产精品国产成人国产三级 |