<legend id='n1DAv'><style id='n1DAv'><dir id='n1DAv'><q id='n1DAv'></q></dir></style></legend>
    <bdo id='n1DAv'></bdo><ul id='n1DAv'></ul>

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

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

    2. 宽度和高度等于它的superView以编程方式使用自动布局?

      Width and Height Equal to its superView using autolayout programmatically?(宽度和高度等于它的superView以编程方式使用自动布局?)
      <tfoot id='A5LYE'></tfoot>

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

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

            • <legend id='A5LYE'><style id='A5LYE'><dir id='A5LYE'><q id='A5LYE'></q></dir></style></legend>

                  <tbody id='A5LYE'></tbody>
              1. <small id='A5LYE'></small><noframes id='A5LYE'>

              2. 本文介绍了宽度和高度等于它的superView以编程方式使用自动布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我一直在网上寻找很多片段,但我仍然找不到我的问题的答案.我的问题是我有一个scrollView(SV),我想以编程方式在scrollView(SV)内添加一个按钮,其父视图的宽度和高度相同,即scrollView(SV),这样当用户旋转设备按钮时,它将具有相同的框架滚动视图(SV).如何做 NSLayout/NSLayoutConstraint?谢谢

                I've been looking for a lot of snippets in the net and I still can't find the answer to my problem. My question is I have a scrollView(SV) and I want to add a button inside scrollView(SV) programmatically with same width and height of its superview which is scrollView(SV) so that when user rotate the device button will have the same frame of scrollView(SV). how to do the NSLayout/NSLayoutConstraint? thanks

                推荐答案

                我不确定这是否是最有效的方法,但它确实有效..

                I'm not sure if this is the most efficient way to do it, but it works..

                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
                button.translatesAutoresizingMaskIntoConstraints = NO;
                // initialize
                
                
                [coverForScrolView addSubview:button];
                
                NSLayoutConstraint *width =[NSLayoutConstraint
                                                    constraintWithItem:button
                                                    attribute:NSLayoutAttributeWidth
                                                    relatedBy:0
                                                    toItem:coverForScrolView
                                                    attribute:NSLayoutAttributeWidth
                                                    multiplier:1.0
                                                    constant:0];
                NSLayoutConstraint *height =[NSLayoutConstraint
                                                     constraintWithItem:button
                                                     attribute:NSLayoutAttributeHeight
                                                     relatedBy:0
                                                     toItem:coverForScrolView
                                                     attribute:NSLayoutAttributeHeight
                                                     multiplier:1.0
                                                     constant:0];
                NSLayoutConstraint *top = [NSLayoutConstraint
                                                   constraintWithItem:button
                                                   attribute:NSLayoutAttributeTop
                                                   relatedBy:NSLayoutRelationEqual
                                                   toItem:coverForScrolView
                                                   attribute:NSLayoutAttributeTop
                                                   multiplier:1.0f
                                                   constant:0.f];
                NSLayoutConstraint *leading = [NSLayoutConstraint
                                                       constraintWithItem:button
                                                       attribute:NSLayoutAttributeLeading
                                                       relatedBy:NSLayoutRelationEqual
                                                       toItem:coverForScrolView
                                                       attribute:NSLayoutAttributeLeading
                                                       multiplier:1.0f
                                                       constant:0.f];
                [coverForScrolView addConstraint:width];
                [coverForScrolView addConstraint:height];
                [coverForScrolView addConstraint:top];
                [coverForScrolView addConstraint:leading];
                

                这篇关于宽度和高度等于它的superView以编程方式使用自动布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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屋-程序员

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

                      <bdo id='4mHHw'></bdo><ul id='4mHHw'></ul>
                      <tfoot id='4mHHw'></tfoot>

                      <legend id='4mHHw'><style id='4mHHw'><dir id='4mHHw'><q id='4mHHw'></q></dir></style></legend>
                    • <small id='4mHHw'></small><noframes id='4mHHw'>