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

具有自定義分頁行為的 UITableView

UITableView with custom paging-like behaviour(具有自定義分頁行為的 UITableView)
本文介紹了具有自定義分頁行為的 UITableView的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試在 UITableView 中為自定義大小的頁面實現分頁.我想要實現的是讓活動單元格的頂部與tableView 的頂部,同時仍顯示 tableView 底部的下一個單元格的頂部(以使用戶滾動并查看更多單元格).

I am trying to implement paging for custom sized pages in the UITableView. What I am trying to achieve is to have the top of the active cell align with the top of the tableView, whilst still showing the top of the next cell at the bottom of the tableView (to incline the user to scroll and see more cells).

我的單元格都等高.

如果我設置 paging=YES 這會導致輕微的偏移量隨著我翻閱頁面而增加.這是由于我的 tableView 比單個單元格略高,并且單元格高度/頁面大小未對齊.

If I set paging=YES this results in a slight offset that increases as I flick through the pages. This is due to my tableView being slightly taller than a single cell and the cell height/page size not aligning.

我在啟用分頁的情況下嘗試了不同的方法.我嘗試將 tableView 的大小設置為單元格的高度,然后關閉剪輯和遮罩,以便用戶仍然可以看到下一個單元格.這不起作用,因為下一個單元格僅在單元格滾動到 tableView 的邊界框之前的最后一毫秒添加到底層滾動視圖.

I have tried different things with paging enabled. I tried setting the size of the tableView to the height of the cell, but then turning off clipping and masking so the user could still see the next cell. This does not work as the next cell is only added to the underlying scrollView at the very last ms before the cell scrolls into the bounding box of the tableView.

然后我開始實現不同的 scrollView 委托方法來模擬分頁行為 - 我似乎無法做到這一點.

I then started implementing the different scrollView delegate methods to mimic the paging behaviour - I can not seem to get it right.

除其他外,我嘗試過這樣的事情:

I have, among other things, tried something like this:

- (void) scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
    float cellHeight = [myCell rowHeight];
    int index = floorf(scrollView.contentOffset.y / cellHeight);

    *targetContentOffset = CGPointMake(targetContentOffset->x, targetContentOffset->y = (index * cellHeight));
}

雖然它做了一些正確的事情,但它的行為與啟用分頁的 scrollView/tableView 完全不同.

While it sort of does the right thing, it behaves nothing like a scrollView/tableView with paging enabled.

我在這里找到了一些試圖實現相同目標的人的帖子,但答案與我自己嘗試過的任何事情一樣具有非本地快照感覺".

I have found a few posts here from people trying to achieve the same thing, but the answers suffer from the same "non-native-snap-feel" that anything I tried myself does.

感謝您提供的任何幫助.

Thanks for any help given.

iOS >= 5.0

推薦答案

實現 scrollViewWillEndDragging:withVelocity:targetContentOffset: 以返回距離 targetContentOffset 最近的單元格的頂部坐標,而不是最接近您的起始偏移量.jjv360 提供的解決方案可以很好地做到這一點,但您可能需要根據單元格的平均高度對其進行一些調整(jjv360 的解決方案可能對非常大的單元格過于活潑).

Implement scrollViewWillEndDragging:withVelocity:targetContentOffset: to return top coordinate of the cell closest to targetContentOffset, not closest to your starting offset. The solution jjv360 provided does that well, but you might want to tweak it a bit depending on how high your cells are on average (jjv360's solution might be too snappy on really big cells).

我想補充一點,您可以通過更改其 decelerationRate 屬性來使 UITableView 的減速更快,使其表現得更像分頁 UIScrollView(只需在 init/viewDidLoad/wherever 中執行一次).

I would just like to add that you can make UITableView's deceleration faster to behave more like paged UIScrollView by changing its decelerationRate property (just do it once in init/viewDidLoad/wherever).

self.tableView.decelerationRate = UIScrollViewDecelerationRateFast;

這篇關于具有自定義分頁行為的 UITableView的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetContentOffset: 不在 UISCrollView 的邊緣工作) - IT屋-程序員軟件開發技術分享社
ImageView Scaling when scrolling down(向下滾動時 ImageView 縮放)
Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的邊界自動更改,帶有內容插圖)
iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干擾按鈕.怎么修?)
Handling scroll views with (custom, interactive) view controller presentation and dismissal(使用(自定義、交互式)視圖控制器呈現和解除處理滾動視圖)
主站蜘蛛池模板: 欧美91| 日韩一区二区三区视频 | 天天人人精品 | 国产成人精品在线播放 | 韩国精品在线观看 | 国产一区二区三区在线 | 精品一区二区免费视频 | 久久久123 | 超碰在线人人干 | 国产一区二区不卡 | 国产成人精品a视频一区www | www.玖玖玖| 欧美精品一区免费 | 国产精品揄拍一区二区 | 91精品国产综合久久久动漫日韩 | 古典武侠第一页久久777 | 91久久国产综合久久 | 免费一区二区三区 | 成人午夜免费福利视频 | 91视频在线看 | 成人精品在线观看 | 亚洲免费人成在线视频观看 | 欧美日韩中文字幕 | 久久久久久久综合 | 精品福利在线 | 综合色播 | 做a视频在线观看 | 色精品| 久久国产精品一区 | 久久精品99国产精品 | 在线看av网址| 91精品国产色综合久久不卡98口 | 亚洲电影中文字幕 | 欧美大片黄 | 国产精品一区二区在线 | 欧美性受xxxx | 视频一区在线观看 | 丁香婷婷成人 | 国产一区二区视频免费在线观看 | 国产精品视屏 | 91视频在线看 |