UITableView 启用分页模式的时候怎样设置才能同时显示上一个 cell 的尾巴和下一个 cell 的脑门? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
lex
V2EX    iDev

UITableView 启用分页模式的时候怎样设置才能同时显示上一个 cell 的尾巴和下一个 cell 的脑门?

  •  
  •   lex
    lexrus 2011-11-07 13:30:12 +08:00 5397 次点击
    这是一个创建于 5161 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <code>-------------------------  ...
    |  |_______________|  |   |
    |   _______________  |   |
    |  | |  |
    |  | | | 4
    |  | 560x420 | | 8
    |  | | | 0
    |  | | |
    |  |_______________| | |
    |   ________________  | |
    |____|_______________|___| ...</code>


    不知道我有没有说清楚,大概的布局如上图所示,而且滚动结束后要保持相同的布局。
    我首先想到的是改 Content Insets 属性,但是没法达到要求。
    9 条回复    1970-01-01 08:00:00 +08:00
    lex
        1
    lex  
    OP
       2011-11-07 13:35:50 +08:00
    -----------------------
    |XXX|_______________|XXX|
    |XXX _______________ XXX|
    |XXX|///////////////|XXX|
    |XXX|///////////////|XXX|
    |XXX|////560x420////|XXX|
    |XXX|///////////////|XXX|
    |XXX|///////////////|XXX|
    |XXX|_______________|XXX|
    |XXX _______________ XXX|
    |___|_______________|___|
    lex
        2
    lex  
    OP
       2011-11-07 13:39:27 +08:00
    不好意思,不知道怎么发等宽字体的贴子,后还是截图吧。
    http://cl.ly/0k0L323b0N2v1Y1Z2r10
    mr_pppoe
        3
    mr_pppoe  
       2011-11-07 17:33:01 +08:00
    看不到图。是不是指scroll停下的时候,头尾的cell都只显式一半?
    remus
        4
    remus  
       2011-11-07 17:46:22 +08:00
    lz说的是像海豚浏览器的标签效果吗?
    lex
        5
    lex  
    OP
       2011-11-07 18:31:13 +08:00
    @mr_pppoe 对的,中间的 cell 完整显示,头尾的 cell 只显示一半。
    mr_pppoe
        6
    mr_pppoe  
       2011-11-08 09:59:29 +08:00
    @lex paging是指scroll总是停留在scrollView frame size的整数倍的位置上。
    所以应该可以:
    1. 把所有的cell的frame上移”cell高度的一半“
    或者
    2. 把第一个cell的高度改成现在”cell高度的一半“

    前提是所有cell等高
    lex
        7
    lex  
    OP
       2011-11-08 11:11:38 +08:00
    早上试了一下,两个做法都不行。
    其实最后要实现的效果是使每次滚动的幅度不是 scrollView frame size 的整数倍,滚动到第 N 页时:
    tableView.contentOffset.y 应该等于 tableView.rowHeight * (N - 1) - (tableView.bounds.size.height - tableView.rowHeight) / 2
    lex
        8
    lex  
    OP
       2011-11-08 11:15:53 +08:00
    网上找到一个滚动效果不太理想的,kPhotoOffsetY 是 (tableView.bounds.size.height - tableView.rowHeight) / 2


    - (void)scrollViewDidEndDecelerating:(UITableView *)tableView {
    int tomove = ((int)tableView.contentOffset.y%(int)tableView.rowHeight);
    if(tomove < tableView.rowHeight/2) [tableView setContentOffset:CGPointMake(0, tableView.contentOffset.y-tomove- kPageOffsetY) animated:YES];
    else [tableView setContentOffset:CGPointMake(0, tableView.contentOffset.y+(tableView.rowHeight-tomove)- kPageOffsetY) animated:YES];
    }
    lex
        9
    lex  
    OP
       2011-11-12 15:54:36 +08:00
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5551 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 41ms UTC 06:30 PVG 14:30 LAX 22:30 JFK 01:30
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86