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
darcy
V2EX  ›  iDev

UITextView在UITableViewCell的自适应问题

  •  
  •   darcy · 2011-12-14 00:00:14 +08:00 · 4984 次点击
    这是一个创建于 4519 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在iOS 5 Reminders(提醒事项)中,输入标题或者备忘录信息时输入框回随着输入内容的多少而改变高度,看上去像是UITextView 在 UITableViewCell做了高度自适应,不知是否正确,求教细节?
    7 条回复    1970-01-01 08:00:00 +08:00
    romoo
        1
    romoo  
       2011-12-14 00:05:08 +08:00
    需要动态计算 UITextView 的高度吧。
    darcy
        2
    darcy  
    OP
       2011-12-14 00:18:13 +08:00
    @romoo 嗯,我不知道获得这个高度以后怎么去更新当前cell的高度。
    ywjno
        3
    ywjno  
       2011-12-14 00:30:38 +08:00
    你确定是uitableviewcell做的么,改变cell的高度是所有一起都要变动的,没法只变动一个cell
    darcy
        4
    darcy  
    OP
       2011-12-14 00:37:49 +08:00
    @ywjno 猜测
    hehuozhao
        6
    hehuozhao  
       2012-02-20 02:35:09 +08:00
    这个帖的最下面一个回答可以解决你的问题,而且确实跟@ywjno所说的一样是用tableView: heightForRowAtIndexPath:改变所有的cell高度.

    http://stackoverflow.com/questions/4015557/uitextview-in-a-uitableviewcell-smooth-auto-resize-shows-and-hides-keyboard-on-i
    ywjno
        7
    ywjno  
       2012-02-20 15:04:34 +08:00
    @lldong @hehuozhao 感谢两位的指点
    我现在的做法是:
    1)固定cell的高度
    2)计算将要放进cell里面的文字的高度,如果超出,则把文字给截断
    3)把经过2)处理的文字给放到cell中

    cc @darcy
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   873 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:32 · PVG 05:32 · LAX 14:32 · JFK 17:32
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.