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

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

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

        iOS AutoLayout - 获取帧大小宽度

        iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)

            <tbody id='unjeN'></tbody>

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

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

                • <tfoot id='unjeN'></tfoot>
                • 本文介绍了iOS AutoLayout - 获取帧大小宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 iOS 6 自动布局进行开发

                  I am developing using iOS 6 auto layout

                  我想记录一条显示视图框架宽度的消息.

                  I would like to log a message displaying the frame width of the view.

                  我可以在屏幕上看到 textView.

                  I can see the textView on the screen.

                  但我得到的宽度和高度为零,我错过了什么吗?

                  But I get the width and height as zero, am I missing something ?

                  NSLog(@"textView    = %p", self.textView);
                  NSLog(@"height      = %f", self.textView.frame.size.height);
                  NSLog(@"width       = %f", self.textView.frame.size.width);
                  
                  textView    = 0x882de00
                  height      = 0.000000
                  width       = 0.000000
                  

                  推荐答案

                  我认为自动布局在你调用它的时候还没有时间来布局你的视图.在调用 viewDidLoad 时自动布局还没有发生,因为它是在视图加载后调用的,并且只有在视图被放置到视图控制器的视图层次结构中并最终布局之后(在视图的 layoutSubviews 方法中).

                  I think auto layout hasn't had the time to layout your views by the time you call this. Auto layout hasn't happened by the time viewDidLoad is called, because it's called just after the views are loaded and it's only after that that the views are placed into the view controller's view hierarchy and eventually laid out (in the view's layoutSubviews method).

                  这个答案指出了为什么问题中的场景不起作用.@dreamzor 的回答指出了将代码放置在何处以解决问题.

                  this answer points out why the scenario in the question doesn't work. @dreamzor's answer points out where to place your code in order to solve it.

                  这篇关于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屋-程序员
                  quot;Auto Layout still required after executing -layoutSubviewsquot; with UITableViewCell subclass(“执行 -layoutSubviews 后仍需要自动布局带有 UITableViewCell 子类)

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

                        <tbody id='W6rB5'></tbody>

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

                            <bdo id='W6rB5'></bdo><ul id='W6rB5'></ul>