<small id='NHG1p'></small><noframes id='NHG1p'>

  • <i id='NHG1p'><tr id='NHG1p'><dt id='NHG1p'><q id='NHG1p'><span id='NHG1p'><b id='NHG1p'><form id='NHG1p'><ins id='NHG1p'></ins><ul id='NHG1p'></ul><sub id='NHG1p'></sub></form><legend id='NHG1p'></legend><bdo id='NHG1p'><pre id='NHG1p'><center id='NHG1p'></center></pre></bdo></b><th id='NHG1p'></th></span></q></dt></tr></i><div id='NHG1p'><tfoot id='NHG1p'></tfoot><dl id='NHG1p'><fieldset id='NHG1p'></fieldset></dl></div>
  • <legend id='NHG1p'><style id='NHG1p'><dir id='NHG1p'><q id='NHG1p'></q></dir></style></legend>
    <tfoot id='NHG1p'></tfoot>
        <bdo id='NHG1p'></bdo><ul id='NHG1p'></ul>

        UITableViewCellContentView 高度怎么可能与 heightForRowAtIndexPath 不

        How is it possible that UITableViewCellContentView height is different from heightForRowAtIndexPath:(UITableViewCellContentView 高度怎么可能与 heightForRowAtIndexPath 不同:)
            <i id='c7Ohy'><tr id='c7Ohy'><dt id='c7Ohy'><q id='c7Ohy'><span id='c7Ohy'><b id='c7Ohy'><form id='c7Ohy'><ins id='c7Ohy'></ins><ul id='c7Ohy'></ul><sub id='c7Ohy'></sub></form><legend id='c7Ohy'></legend><bdo id='c7Ohy'><pre id='c7Ohy'><center id='c7Ohy'></center></pre></bdo></b><th id='c7Ohy'></th></span></q></dt></tr></i><div id='c7Ohy'><tfoot id='c7Ohy'></tfoot><dl id='c7Ohy'><fieldset id='c7Ohy'></fieldset></dl></div>

            <tfoot id='c7Ohy'></tfoot>

              <small id='c7Ohy'></small><noframes id='c7Ohy'>

                <tbody id='c7Ohy'></tbody>

              • <bdo id='c7Ohy'></bdo><ul id='c7Ohy'></ul>

                1. <legend id='c7Ohy'><style id='c7Ohy'><dir id='c7Ohy'><q id='c7Ohy'></q></dir></style></legend>
                  本文介绍了UITableViewCellContentView 高度怎么可能与 heightForRowAtIndexPath 不同:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 UITableView 遇到了一个非常奇怪的问题.我有一些不同的单元格要显示在类似新闻源的表格视图中.

                  I'm facing a really weird problem on my UITableView. I have some different cells that I want to display on a newsfeed-like table view.

                  重复使用后的单元格出现问题.该单元格包含两个图像、两个标签和一个带有分享/喜欢/评论按钮的视图.我会试着画它,但我不确定它会不会漂亮:

                  And I have a problem with a cell after reuse. The cell contains two images, two labels and a view with the share/like/comment buttons. I'm gonna try to draw it, but I'm not sure it's gonna be pretty :

                  -------------------------------------------------
                  |       |   __    ____________________________  |
                  |       |  |_2|  |                            | |
                  |       |        |              3             | |
                  |       |        |                            | |
                  |   1   |        |____________________________| |
                  |       |                                       |
                  |       |_______________________________________|
                  |       |                                       |
                  |       |                  4                    |
                  |_______|_______________________________________|
                  |                                               |
                  |                       5                       |
                  |_______________________________________________|
                  
                  1 : objectImage
                  2 : subjectImage
                  3 : titleLabel
                  4 : commentLabel
                  5 : actionsView
                  

                  我的限制是:

                  "H:|-0-[objectImage(60)]-7-[subjectImage(30)]-7-[titleLabel]-7-|"
                  "H:|-0-[objectImage(60)]-0-[commentLabel]-0-|"
                  "H:|-0-[actionsView]-0-|"
                  "V:|-0-[objectImage(>=35)]-0-[actionsView(44)]-0-|"
                  "V:|-7-[subjectImage(30)]"
                  "V:|-7-[titleLabel(>=46)]-7-[commentLabel(>=35)]-0-[actionsView(44)]-0-|"
                  

                  并且每次绘制单元格时,我都会更改此约束:

                  And every time the cell is drawn, I change this constraint:

                  "V:[commentLabel(%0.2f)]"
                  

                  单元格第一次完美显示.

                  The cells display perfectly the first time.

                  但是,我遇到的问题是,在某个时间点,经过一些重用(我无法每次都重现它),应用程序由于约束问题而崩溃.这是一个例外:

                  But, the problem I have is that at a point, after some reuse (I can't reproduce it every time) the app crashes because of a constraint problem. Here is the exception:

                  "<NSLayoutConstraint:0x205a75b0 V:[UILabel:0x1ef31430(105)]>",
                  "<NSLayoutConstraint:0x1ef34440 V:[UILabel:0x1ef31430]-(0)-[UIView:0x1ef2fe50]>",
                  "<NSLayoutConstraint:0x1ef34380 V:[UILabel:0x1ef31250]-(7)-[UILabel:0x1ef31430]>",
                  "<NSLayoutConstraint:0x1ef33900 V:|-(7)-[UILabel:0x1ef31250]   (Names: '|':UITableViewCellContentView:0x1ef2bf50 )>",
                  "<NSLayoutConstraint:0x1ef34340 V:[UILabel:0x1ef31250(>=46)]>",
                  "<NSLayoutConstraint:0x1ef33210 V:[UIView:0x1ef2fe50]-(0)-|   (Names: '|':UITableViewCellContentView:0x1ef2bf50 )>",
                  "<NSLayoutConstraint:0x1ef331d0 V:[UIView:0x1ef2fe50(44)]>",
                  "<NSAutoresizingMaskLayoutConstraint:0x1ef36f90 h=--& v=--& V:[UITableViewCellContentView:0x1ef2bf50(147)]>"
                  
                  
                  Will attempt to recover by breaking constraint 
                  <NSLayoutConstraint:0x1ef34380 V:[UILabel:0x1ef31250]-(7)-[UILabel:0x1ef31430]>
                  

                  问题是约束 [UITableViewCellContentView:0x1ef2bf50(147)] 不正确.

                  The problem is that the constraint [UITableViewCellContentView:0x1ef2bf50(147)] is not right.

                  奇怪的是,heightForRowAtIndexPath: 返回的正确值是 217.

                  What is weird is that the heightForRowAtIndexPath: returns the correct value which is 217.

                  而我不明白的是 UITableViewCell 的高度是正确的!

                  And what I don't understand is that the height of the UITableViewCell is correct!

                  (lldb) po 0x1ef2bf50
                  $0 = 519225168 <UITableViewCellContentView: 0x1ef2bf50; frame = (0 0; 320 147); gestureRecognizers = <NSArray: 0x1ef30a20>; layer = <CALayer: 0x1ef2a3d0>>
                  (lldb) po [0x1ef2bf50 superview]
                  $1 = 0x1ef30e40 <NewsSubjectCommentCell: 0x1ef30e40; baseClass = UITableViewCell; frame = (0 1055; 320 217); hidden = YES; autoresize = W; layer = <CALayer: 0x1ef25e10>>
                  

                  所以我不明白 UITableViewCellContentView 的高度约束怎么可能是147,是另一个同类型单元格的高度,但是应该改成209吧?

                  So I don't understand how is it possible that the height constraint of UITableViewCellContentView is 147. It is the height of another cell of the same type, but it should be changed to 209, right?

                  所以,如果您对这是如何发生的有任何见解(也许我做错了什么),我会很高兴.

                  So, if you have any insight on how this can happen (maybe I did something wrong), I'd be glad.

                  谢谢,

                  推荐答案

                  我在这里找到了答案:iOS7 UITableViewCell 中的自动布局约束问题

                  我们只需要将 contentView 的 AutoresizingMask 设置为 UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth 并...问题解决了!

                  We just have to set the AutoresizingMask of the contentView to UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth and ... problem solved!

                  这篇关于UITableViewCellContentView 高度怎么可能与 heightForRowAtIndexPath 不同:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                    <bdo id='v5EMX'></bdo><ul id='v5EMX'></ul>

                          <small id='v5EMX'></small><noframes id='v5EMX'>

                            <tbody id='v5EMX'></tbody>

                          • <i id='v5EMX'><tr id='v5EMX'><dt id='v5EMX'><q id='v5EMX'><span id='v5EMX'><b id='v5EMX'><form id='v5EMX'><ins id='v5EMX'></ins><ul id='v5EMX'></ul><sub id='v5EMX'></sub></form><legend id='v5EMX'></legend><bdo id='v5EMX'><pre id='v5EMX'><center id='v5EMX'></center></pre></bdo></b><th id='v5EMX'></th></span></q></dt></tr></i><div id='v5EMX'><tfoot id='v5EMX'></tfoot><dl id='v5EMX'><fieldset id='v5EMX'></fieldset></dl></div>

                            <tfoot id='v5EMX'></tfoot>
                            <legend id='v5EMX'><style id='v5EMX'><dir id='v5EMX'><q id='v5EMX'></q></dir></style></legend>