title: How to access the correct cell width inside a UITabelViewCell Class?
body: <p>I am trying to obtain the correct width for a custom cell inside a UITableViewCell Class. I tried the below:</p>
  
  <pre><code>    import UIKit
  
      import ChameleonFramework
  
      class IsectionsCustomTableViewCell: UITableViewCell {
  
          let cellContainer: UIView = {
  
              let container = UIView()
  
              container.backgroundColor = UIColor.flatPink()
  
              container.translatesAutoresizingMaskIntoConstraints = false
  
              return container
  
          }()
  
      override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
  
              super.init(style: style, reuseIdentifier: reuseIdentifier)
  
              addSubview(cellContainer)
  
      }
  
          required init?(coder aDecoder: NSCoder) {
  
              fatalError("init(coder:) has not been implemented")
  
          }
  
      func applyAppropriateSizeAndConstraintsForCellItems() {
  
              NSLayoutConstraint.activate([
  
                  cellContainer.topAnchor.constraint(equalTo: self.topAnchor),
  
                  cellContainer.rightAnchor.constraint(equalTo: self.rightAnchor, constant: -1*((self.frame.size.width)/2)),
  
                  cellContainer.bottomAnchor.constraint(equalTo: self.bottomAnchor),
  
                  cellContainer.leftAnchor.constraint(equalTo: self.leftAnchor)
  
  ])
      }
  
      }
  </code></pre>
  
  <p>However, as it can be seen from the attached image, the below line of code used above did not return the correct width as the total width was not split equally in half:</p>
  
  <pre><code>-1*((self.frame.size.width)/2)
  </code></pre>
  
  <p>Any idea what did I do wrong here, how can I obtain the true width of the custom Cell, which in my mind should be equal to the width of the Table it is going to be placed inside?</p>
  
  <p>Regards,
  Shadi Hammoudeh.<a href="https://i.stack.imgur.com/FkigU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FkigU.png" alt="enter image description here"></a></p>