在 stackoverflow 提了个问题,一直无人回答 - 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
heqichang
V2EX    iDev

在 stackoverflow 提了个问题,一直无人回答

  •  
  •   heqichang
    heqichang 2017 年 3 月 8 日 9288 次点击
    这是一个创建于 3260 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在 stackoverflow 提了个问题,但是苦于自己英文水平,中间 on hold 编辑了几次。这样是不是上面的大牛们都看不到这个问题了?浏览量很少哩。我可以删除旧问题,重新提问吗?

    顺道求 v2 上的老司机看看有人遇到同样的问题吗?

    http://stackoverflow.com/questions/42406686/uitableview-will-change-contentoffset-in-ios8-with-swift3-is-this-a-swift3-bug
    第 1 条附言    2017 年 3 月 8 日
    问题中文版:
    tableview 里每个 cell 高度不同,加载新的数据 reloadData 后,用 swift3 ios8 下的 tableview 会自动改变 contentOffset ,但是同样的代码逻辑,同样的机器用 swift2 不会改变 contentOffset 。写了个 demo 在这里 https://github.com/heqichang/swift3-tableview-issue
    39 条回复    2019-01-18 11:14:58 +08:00
    bjzhou1990
        1
    bjzhou1990  
       2017 年 3 月 8 日
    -2 .....

    在这里用中文描述一遍?
    knight322
        2
    knight322  
       2017 年 3 月 8 日
    看到有人回答了哦
    Mine
        3
    Mine  
       2017 年 3 月 8 日
    不是有人回答你吗?/div>
    bytenoob
        4
    bytenoob  
       2017 年 3 月 8 日
    估计是因为英文太差了所以-2.。。
    bombless
        5
    bombless  
       2017 年 3 月 8 日
    ……就你提供的这些信息别人根本无从重现
    paradoxs
        6
    paradoxs  
       2017 年 3 月 8 日
    发在那里没意思, 你要是用中文在这里发, 分分钟解决了.
    isCyan
        7
    isCyan  
       2017 年 3 月 8 日 via Android   1
    @paradoxs 并不是这样哦
    heqichang
        8
    heqichang  
    OP
       2017 年 3 月 8 日
    @bjzhou1990 tableview 里每个 cell 高度不同,加载新的数据 reloadData 后,用 swift3 ios8 下的 tableview 会自动改变 contentOffset ,但是同样的代码逻辑,同样的机器用 swift2 不会改变 contentOffset 。写了个 demo 在这里 https://github.com/heqichang/swift3-tableview-issue
    heqichang
        9
    heqichang  
    OP
       2017 年 3 月 8 日
    @knight322 回答的不是我问的问题,估计是我编辑之前没描述准确
    heqichang
        10
    heqichang  
    OP
       2017 年 3 月 8 日
    @Yc1992 是啊,重新编辑问题还花了我半天...英文表述是硬伤
    wtser
        11
    wtser  
       2017 年 3 月 8 日
    jadecoder
        12
    jadecoder  
       2017 年 3 月 8 日
    一个周无回答无评论可以获得一个风滚草徽章, lz 得到了吗?
    heqichang
        13
    heqichang  
    OP
       2017 年 3 月 8 日
    @wtser ,也发布问题了,还早于 stackoverflow ,就是没人回答才上的 stackoverflow 。 https://segmentfault.com/q/1010000008453554
    heqichang
        14
    heqichang  
    OP
       2017 年 3 月 8 日
    @jadecoder 啥?这还能有成就达成?
    chipmuck
        15
    chipmuck  
       2017 年 3 月 8 日
    @heqichang segmentfault 就别提了,基本没人会去回复的。问题的质量也不高。
    nagato
        16
    nagato  
       2017 年 3 月 8 日
    每次 reload 你的 height 都变了?
    xuboying
        17
    xuboying  
       2017 年 3 月 8 日 via Android
    so 看问题的。 py 一类的都是秒回
    太独特的问题没回答的。很正常。
    sf 就算了。
    airbob
        18
    airbob  
       2017 年 3 月 8 日
    没有复现你的问题,两个 demo 都试了
    heqichang
        19
    heqichang  
    OP
       2017 年 3 月 8 日
    @nagato 没有啊, height 的顺序没变,都是一个固有顺序,只是每个 cell 高度不一样
    heqichang
        20
    heqichang  
    OP
       2017 年 3 月 8 日
    @airbob 哦?你的测试机型和系统是什么哩?我手上只有三台测试机,所以无法确定覆盖所有版本。我测试有问题的机器是 iphone5s ,系统是 8.4 。其它 ios8 系统没测过。我这还有两台 ios10 的机子就没问题。
    airbob
        21
    airbob  
       2017 年 3 月 8 日
    @heqichang 必须用测试机么, simulator 能复现吗?
    heqichang
        22
    heqichang  
    OP
       2017 年 3 月 8 日
    @airbob 你是 ios8 的 simulator 吗?我不确定,因为我没在 simulator 测试过,我这里本地只有 ios10 的 simulator ,没下 ios8 的。
    airbob
        23
    airbob  
       2017 年 3 月 8 日
    @heqichang 是的我用的 simulator, 手头上没有 iOS8 device
    heqichang
        24
    heqichang  
    OP
       2017 年 3 月 8 日
    @airbob 我去下载个旧版本 simulator 试试哈。顺道吐槽下 Xcode 里下载旧版本的 simulator 太慢了。。。
    airbob
        25
    airbob  
       2017 年 3 月 8 日
    dapeng
        26
    dapeng  
       2017 年 3 月 8 日
    楼主,你的中文问题描述呢
    heqichang
        27
    heqichang  
    OP
       2017 年 3 月 8 日
    @dapeng 已重新 append 上了
    congeec
        28
    congeec  
       2017 年 3 月 8 日 via iPad   1
    @chipmuck 而且在 segfault 上解决了人家的问题,连个赞都没有
    heqichang
        29
    heqichang  
    OP
       2017 年 3 月 8 日
    @airbob 是啊,你的看起来没问题,有问题的话,它的 contentOffset 会有比较大的跳跃。话说的我的 simulator 挂机到现在还没下载完。。。
    heqichang
        30
    heqichang  
    OP
       2017 年 3 月 8 日
    @airbob 我下载好 iOS8 的模拟器了, iOS 8.4 的系统,可以重现这个问题的。当加载完多余一屏的色块时,会看到 tableview 有明显的跳动,多加载几个色块之后,往上面滑动也会看到明显的跳跃。
    heqichang
        31
    heqichang  
    OP
       2017 年 3 月 8 日
    @airbob 这里是我的 log

    https://gist.github.com/heqichang/89e9f2e29f29b1f39627340313510a1b

    注意看里面 446.0 , 554.5 这些地方,明显的有一次大跳跃
    chipmuck
        32
    chipmuck  
       2017 年 3 月 8 日   1
    @congeec 给你一个赞!
    InfinitySam
        33
    InfinitySam  
       2017 年 3 月 12 日
    楼主,我想问问你 cell height 是算出来的么。。。? 还有视觉上有什么不同,你的意思好像是 reload 后 cell 的垂直位置变化了,对吧?
    heqichang
        34
    heqichang  
    OP
       2017 年 3 月 13 日
    @InfinitySam 我随手写的固定的一个高度序列,[150, 500, 150, 150, 150, 300, 100, 300]。是啊,垂直位置发生了变化,但是,同样的代码, 我这里测试,只有在 ios8 ,并且是 swift3 上才会出现这个问题,模拟器 ios8 上也能复现。
    xiabob
        35
    xiabob  
       2017 年 3 月 13 日
    是的,我迁移到 swift3 ,在 iOS8 上也有这个问题, func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat 方法调用有问题, IndexPath 不全,你也可以测一下
    heqichang
        36
    heqichang  
    OP
       2017 年 3 月 13 日
    @xiabob 是啊,好像是这样的,调 reload 后在 heightForRowAt 方法里的 IndexPath 数目不对,总是少 1 个。你们解决这个问题了吗?
    xiabob
        37
    xiabob  
       2017 年 3 月 14 日
    tableView(_ tableView: UITableView, numberOfRowsInSection section: Int)返回 1 , func numberOfSections(in tableView: UITableView) -> Int 返回具体的数目,是可行的,不过局限太多了
    heqichang
        38
    heqichang  
    OP
       2017 年 3 月 14 日
    @xiabob 我去!聪明啊!你这方法真可以,把 section 和 row 反一下。真坑爹!幸好正式项目里没有用到多 section ,但只针对 ios 8 来改动的地方还是蛮多的。
    soverflowchina
        39
    soverflowchina  
       2019 年 1 月 18 日
    这里肯定有人回答的:
    https://www.stackoverflowchina.com
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1871 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 40ms UTC 15:41 PVG 23:41 LAX 07:41 JFK 10:41
    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