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 · Dec 14, 2011 · 5667 views
    This topic created in 5272 days ago, the information mentioned may be changed or developed.
    在iOS 5 Reminders(提醒事项)中,输入标题或者备忘录信息时输入框回随着输入内容的多少而改变高度,看上去像是UITextView 在 UITableViewCell做了高度自适应,不知是否正确,求教细节?
    7 replies    1970-01-01 08:00:00 +08:00
    romoo
        1
    romoo  
       Dec 14, 2011
    需要动态计算 UITextView 的高度吧。
    darcy
        2
    darcy  
    OP
       Dec 14, 2011
    @romoo 嗯,我不知道获得这个高度以后怎么去更新当前cell的高度。
    ywjno
        3
    ywjno  
       Dec 14, 2011
    你确定是uitableviewcell做的么,改变cell的高度是所有一起都要变动的,没法只变动一个cell
    darcy
        4
    darcy  
    OP
       Dec 14, 2011
    @ywjno 猜测
    hehuozhao
        6
    hehuozhao  
       Feb 20, 2012
    这个帖的最下面一个回答可以解决你的问题,而且确实跟@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  
       Feb 20, 2012
    @lldong @hehuozhao 感谢两位的指点
    我现在的做法是:
    1)固定cell的高度
    2)计算将要放进cell里面的文字的高度,如果超出,则把文字给截断
    3)把经过2)处理的文字给放到cell中

    cc @darcy
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1039 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 18:55 · PVG 02:55 · LAX 11:55 · JFK 14:55
    ♥ Do have faith in what you're doing.