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

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

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

問(wèn)題描述

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

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

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

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

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

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?

謝謝.

推薦答案

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

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.

任何滾動(dòng)動(dòng)作的通用解決方案是這樣的:

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(可能更早)開(kāi)始,這似乎也可以工作

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 中的滾動(dòng)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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 - 如何從照片庫(kù)中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁(yè)面之間的照片應(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 在滾動(dòng)時(shí)暫停 NSTimer)
主站蜘蛛池模板: 国产在线视频一区二区 | 少妇一级淫片免费观看 | 51成人网| 国产精品偷拍 | 香蕉综合网 | 国产一区二区在线看 | www.国产一区 | 日韩免费| 日本少妇视频 | www.草| 亚洲成人免费视频 | 国产盗摄视频 | 一级大片免费看 | 国产精品99精品久久免费 | 一区二区福利 | 色爽视频| 亚洲视频在线免费观看 | 四虎官网 | 在线a| a级片免费观看 | 免费av在线 | 天天干视频 | 国产黄色大片 | 一级做a爰片久久毛片潮喷 视频一二区 | 懂色av一区二区三区 | 自拍偷拍综合 | 一区二区不卡视频 | 操操av| a天堂视频 | 久久久久久久久久国产 | 国产精品偷乱一区二区三区 | 黄色一级片视频 | 毛片视频网站 | 日韩一区二区免费视频 | 国产成人综合视频 | 在线一级片 | 中文字幕日本 | 国产日韩在线播放 | 天天插天天透 | 久久99精品久久久久久琪琪 | 一二三区视频 |