<tfoot id='6CBT3'></tfoot>

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

      <small id='6CBT3'></small><noframes id='6CBT3'>

    1. 标签显示屏幕顶部而不是在 inputAccessoryView

      label showing top of screen instead of being on the inputAccessoryView(标签显示屏幕顶部而不是在 inputAccessoryView)

          <tbody id='DZZKv'></tbody>

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

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

            <legend id='DZZKv'><style id='DZZKv'><dir id='DZZKv'><q id='DZZKv'></q></dir></style></legend>

              • <tfoot id='DZZKv'></tfoot>
                本文介绍了标签显示屏幕顶部而不是在 inputAccessoryView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这是我的代码:

                 var messageView : UITextView = {
                        var textView = UITextView()
                        textView.text = "   Add your message here"
                        textView.textColor = UIColor.lightGrayColor()
                        textView.translatesAutoresizingMaskIntoConstraints = false
                        textView.backgroundColor = UIColor.lightGrayColor()
                        textView.layer.cornerRadius = 3
                        textView.clipsToBounds = true
                        textView.keyboardAppearance = .Dark
                        textView.layer.borderWidth = 1.0
                        textView.layer.borderColor = UIColor.lightGrayColor()
                        textView.autocorrectionType = .no
                
                
                        // MARK: Setup accesorryView
                
                        let label = UILabel()
                        label.text = "You have a 100 character limit"
                        label.translatesAutoresizingMaskIntoConstraints = false
                
                        let accessoryView = UIView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, 44))
                        accessoryView.backgroundColor = UIColor.redColor()
                
                        accessoryView.addSubview(label)
                
                        accessoryView.leadingAnchor.constraintEqualToAnchor(label.leadingAnchor, constant: 18)
                        accessoryView.centerYAnchor.constraintEqualToAnchor(label.centerYAnchor)
                
                        textView.inputAccessoryView = accessoryView
                
                        return textView
                    }()
                

                我正在尝试将 inputAccessoryView 添加到我的 TextView 的键盘.我的 inputAccessoryView 必须有一个标签说你有 100 个字符的限制"...

                I'm trying to add an inputAccessoryView to my TextView's keyboard. My inputAccessoryView must have a label saying "You have a 100 character limit"...

                但我目前的结果是:

                蓝色的文本...正是我想要在 inputAccessoryView 中出现的标签,但它在我的屏幕顶部...

                The text in the blue...is exactly the label I want to be in the inputAccessoryView, but it's on the top of my screen...

                推荐答案

                需要将标签上的translatesAutoresizingMaskIntoConstraints设置为falseisActivetrue 上的约束.基本上你的约束代码应该是这样的:

                You need to set translatesAutoresizingMaskIntoConstraints on the label to false and isActive to true on the constraints. Basically your constrains code should look like this:

                accessoryView.leadingAnchor.constraintEqualToAnchor(label.leadingAnchor, constant: 18).isActive = true
                accessoryView.centerYAnchor.constraintEqualToAnchor(label.centerYAnchor).isActive = true
                

                这篇关于标签显示屏幕顶部而不是在 inputAccessoryView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                How do I size a UITextView to its content?(如何根据内容调整 UITextView 的大小?)
                How to format localised strings in Swift?(如何在 Swift 中格式化本地化字符串?)
                Why do we need to set delegate to self? Why isn#39;t it defaulted by the compiler?(为什么我们需要将委托设置为自我?为什么编译器不默认它?)
                  <tbody id='LGyVG'></tbody>

                <legend id='LGyVG'><style id='LGyVG'><dir id='LGyVG'><q id='LGyVG'></q></dir></style></legend>

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

                  <tfoot id='LGyVG'></tfoot>

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