<tfoot id='MSTRp'></tfoot>

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

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

      1. <legend id='MSTRp'><style id='MSTRp'><dir id='MSTRp'><q id='MSTRp'></q></dir></style></legend>

      2. Swift:以编程方式在 UICollectionViewCell 中的 IndexPath 中的多个 UIButton

        Swift: Multiple UIButton in a IndexPath in a UICollectionViewCell programmatically, next addTarget does not click(Swift:以编程方式在 UICollectionViewCell 中的 IndexPath 中的多个 UIButton,下一个 addTarget 不单击) - IT屋-程序员软件开发技术分
          <tbody id='KHynu'></tbody>
          • <small id='KHynu'></small><noframes id='KHynu'>

              <tfoot id='KHynu'></tfoot>
              • <bdo id='KHynu'></bdo><ul id='KHynu'></ul>

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

                  <i id='KHynu'><tr id='KHynu'><dt id='KHynu'><q id='KHynu'><span id='KHynu'><b id='KHynu'><form id='KHynu'><ins id='KHynu'></ins><ul id='KHynu'></ul><sub id='KHynu'></sub></form><legend id='KHynu'></legend><bdo id='KHynu'><pre id='KHynu'><center id='KHynu'></center></pre></bdo></b><th id='KHynu'></th></span></q></dt></tr></i><div id='KHynu'><tfoot id='KHynu'></tfoot><dl id='KHynu'><fieldset id='KHynu'></fieldset></dl></div>
                  本文介绍了Swift:以编程方式在 UICollectionViewCell 中的 IndexPath 中的多个 UIButton,下一个 addTarget 不单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我以编程方式在 UICollectionViewCell 的 indexPath 中创建了多个 UIButton.现在我想打印单击添加到收藏夹",但单击 UIButton 后它没有打印任何内容.UIButton 确实可以查看除 addTarget 功能之外的所有内容,但未单击.

                  I made multiple UIButton in a indexPath in a UICollectionViewCell programmatically. now i want to print "clicked add to favourite" but it is not printing anything after click UIButton. the UIButton does view everything except addTarget function not click.

                  import UIKit
                  
                  //**UICollectionViewCell**
                  class DescriptionCell: UICollectionViewCell, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
                  
                  
                      override init(frame: CGRect) {
                          super.init(frame: frame)
                  
                  
                          setupCell()
                  
                      }
                  
                      required init?(coder aDecoder: NSCoder) {
                          fatalError("init(coder:) has not been implemented")
                      }
                  
                  
                  
                      lazy var addToCart: UIButton = {
                  
                          let btn = UIButton()
                          btn.setTitle("Add to favourite", for: .normal)
                          btn.isUserInteractionEnabled = true
                          btn.setTitleColor(.white, for: .normal)
                  
                          btn.backgroundColor = UIColor.orange
                          btn.titleLabel?.font = UIFont.boldSystemFont(ofSize: 8)
                          btn.titleLabel?.textAlignment = .right
                  
                          // addToCart not click
                          btn.addTarget(self, action: #selector(addToCartTarget), for: .touchUpInside)
                  
                          btn.layer.cornerRadius = 12
                  
                          return btn
                      }()
                  
                  
                  
                  
                      func setupCell() {
                  
                  
                  
                          addSubview(addToCart)
                  
                  
                  
                          addConstraintsWithFormat("H:|-80-[v0]-80-|", views: addToCart)
                               addConstraintsWithFormat("V:|-380-[v0(25)]|", views: addToCart)
                  
                  
                      }
                  
                  
                  
                      func addToCartTarget() {
                  
                          print("you clicked add to favourite")
                      }
                  
                  
                  
                  
                  }
                  

                  推荐答案

                  尝试用如下框架初始化按钮:

                  Try initializing button with frame like:

                  let btn = UIButton(frame: CGRect(x: 10, y: 10, width: 50, height: 20))
                  

                  这篇关于Swift:以编程方式在 UICollectionViewCell 中的 IndexPath 中的多个 UIButton,下一个 addTarget 不单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  UIButton title text color(UIButton 标题文本颜色)
                  Stretch background image for UIButton(为 UIButton 拉伸背景图像)
                  Using Tint color on UIImageView(在 UIImageView 上使用 Tint 颜色)
                  How can I change UIButton title color?(如何更改 UIButton 标题颜色?)
                  iPhone UIButton - image position(iPhone UIButton - 图像位置)
                  UIButton remove all target-actions(UIButton 删除所有目标动作)
                1. <small id='0HnHq'></small><noframes id='0HnHq'>

                        <legend id='0HnHq'><style id='0HnHq'><dir id='0HnHq'><q id='0HnHq'></q></dir></style></legend>

                          <tbody id='0HnHq'></tbody>

                        <tfoot id='0HnHq'></tfoot>
                          <bdo id='0HnHq'></bdo><ul id='0HnHq'></ul>

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