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

交叉方向 UIScrollViews - 我可以修改滾動行為嗎?

Cross Directional UIScrollViews - Can I Modify the Scrolling Behaviour?(交叉方向 UIScrollViews - 我可以修改滾動行為嗎?)
本文介紹了交叉方向 UIScrollViews - 我可以修改滾動行為嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

滾動視圖的工作原理如下: 一個滾動視圖在水平方向啟用分頁.此滾動視圖的每個頁面"都包含一個垂直滾動的 UITableView.如果不進行修改,這可以正常工作,但并不完美.

Here's how the scroll views work: One scroll view is paging enabled in the horizontal direction. Each 'page' of this scroll view contains a vertically scrolling UITableView. Without modification, this works OK, but not perfectly.

不正確的行為:當用戶在表格視圖上上下滾動,但又想快速翻到下一頁時,水平滑動/滑動最初不起作用 -在表格視圖靜止之前它不會起作用(即使滑動非常明顯是水平的).

The behaviour that's not right: When the user scrolls up and down on the table view, but then wants to flick over to the next page quickly, the horizontal flick/swipe will not work initially - it will not work until the table view is stationary (even if the swipe is very clearly horizontal).

它應該如何工作:如果滑動明顯是水平的,即使表格視圖仍在滾動/彈跳,我也希望頁面發生變化,因為這也是用戶所期望的.

How it should work: If the swipe is clearly horizontal, I'd like the page to change even if the table view is still scrolling/bouncing, as this is what the user will expect too.


我怎樣才能改變這種行為 - 最簡單或最好的方法是什么?


注意 由于各種原因,某些答案中所述的 UIPageViewController 將不起作用.我如何使用交叉方向 UIScrollViews 來做到這一點(/one 是一個表格視圖,但你明白了)?我已經用頭撞墻了好幾個小時了——如果你認為你能做到這一點,那么我會很樂意獎勵賞金.


NOTE For various reasons, a UIPageViewController as stated in some answers will not work. How can I do this with cross directional UIScrollViews (/one is a table view, but you get the idea)? I've been banging my head against a wall for hours - if you think you can do this then I'll more than happily award a bounty.

推薦答案

根據我對問題的理解,只有在 tableView 滾動時,我們才想更改默認行為.所有其他行為都將相同.

According to my understanding of the question, it is only while the tableView is scrolling we want to change the default behaviour. All the other behaviour will be the same.

子類 UITableView.UITableViewUIScrollView 的子類.在 UITableView 子類上實現一個 UIScrollViewUIGestureRecognizer 的委托方法

SubClass UITableView. UITableViews are subClass of UIScrollViews. On the UITableView subClass implement one UIScrollView's UIGestureRecognizer's delegate method

- (BOOL)gestureRecognizer:(UIPanGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UISwipeGestureRecognizer *)otherGestureRecognizer
{
    //Edit 1
    //return self.isDecelerating;
    //return self.isDecelerating | self.bounces; //If we want to simultaneous gesture on bounce and scrolling
    //Edit 2
    return self.isDecelerating || self.contentOffset.y < 0 || self.contentOffset.y > MAX(0, self.contentSize.height - self.bounds.size.height); // @Jordan edited - we don't need to always enable simultaneous gesture for bounce enabled tableViews
}

因為我們只想在 tableView 減速時更改默認手勢行為.

As we only want to change the default gesture behaviour while the tableView is decelerating.

現在將所有 'UITableView 的類更改為您新創建的 tableViewSubClass 并運行項目,當 tableView 滾動時滑動應該可以工作.:]

Now change all 'UITableView's class to your newly created tableViewSubClass and run the project, swipe should work while tableView is scrolling. :]

但是當 tableView 滾動時,滑動看起來有點太敏感了.讓我們對滑動進行一些限制.

But the swipe looks a little too sensitive while tableView is scrolling. Let's make the swipe a little restrictive.

子類 UIScrollView.在 UIScrollView 子類上實現另一個 UIGestureRecognizer 的委托方法 gestureRecognizerShouldBegin:

SubClass UIScrollView. On the UIScrollView subclass implement another UIGestureRecognizer's delegate method gestureRecognizerShouldBegin:

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer 
{
    if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
        CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self];
        if (abs(velocity.y) * 2 < abs(velocity.x)) {
            return YES;
        }
    }
    return NO;
}

我們想讓滑動清晰地水平".上面的代碼僅在 x 軸上的手勢速度是 y 軸上的兩倍時才允許手勢開始.[如果您愿意,請隨意增加硬編碼值2".值越高,滑動需要越水平.]

We want to make the "swipe is clearly horizontal". Above code only permits gesture begin if the gesture velocity on x axis is double than on y axis. [Feel free to increase the hard coded value "2" if your like. The higher the value the swipe needs to be more horizontal.]

現在將UiScrollView"類(具有多個 TableView)更改為您的 ScrollViewSubClass.運行項目.:]

Now change the `UiScrollView' class (which has multiple TableViews) to your ScrollViewSubClass. Run the project. :]

我在 gitHub 上做了一個項目https://github.com/rishi420/SwipeWhileScroll

I've made a project on gitHub https://github.com/rishi420/SwipeWhileScroll

這篇關于交叉方向 UIScrollViews - 我可以修改滾動行為嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

iOS - Using storyboard and autolayout to center the UIScrollView(iOS - 使用故事板和自動布局使 UIScrollView 居中)
get index or tag value from imageview tap gesture(從 imageview 點擊手勢獲取索引或標簽值)
UIScrollView not scrolling regardless of large contentSize(無論內容大小如何,UIScrollView 都不會滾動)
UIScrollView zooming with Auto Layout(UIScrollView 使用自動布局縮放)
iOS/Swift - Hide/Show UITabBarController when scrolling down/up(iOS/Swift - 向下/向上滾動時隱藏/顯示 UITabBarController)
Programmatically force a UIScrollView to stop scrolling, for sharing a table view with multiple data sources(以編程方式強制 UIScrollView 停止滾動,以便與多個數據源共享表格視圖) - IT屋-程序員軟件開發技術分享
主站蜘蛛池模板: 欧美成人激情视频 | 久久精品国产精品青草 | 羞羞的视频免费看 | 中文字幕精品一区 | 成人精品在线视频 | 在线一级片 | 色橹橹欧美在线观看视频高清 | 国产精品视频导航 | 91n成人 | 欧美日一区二区 | 黄网站免费在线观看 | www成人免费视频 | a级毛片毛片免费观看久潮喷 | 久久小视频 | 国产精品久久久久久久久久软件 | 久久高潮 | 国产精品毛片av一区 | 最新黄色在线观看 | 天天天天操 | 欧美一区二区三区视频 | 一区二区av | 欧产日产国产精品视频 | 老外几下就让我高潮了 | 色综合天天天天做夜夜夜夜做 | 99色在线视频 | 国产色| 亚洲成人观看 | 午夜爱爱毛片xxxx视频免费看 | 久久久久久免费毛片精品 | 国产精品亚洲综合 | 中文字幕在线一区二区三区 | 国产一区二区日韩 | 日韩一区三区 | 免费看爱爱视频 | 久久国产精品一区二区三区 | 久久久精品综合 | 亚洲一区二区三区四区av | 青青草视频网 | 国产亚洲第一页 | 色欧美片视频在线观看 | 欧美xxxⅹ性欧美大片 |