Trying to horizontally center my dynamic UITableViewCell. I want the width to remain the same despite screen size, just centered. Using the code I have below, my dynamic cells appear (still left justified) but now the prototype cell I've set up in my .xib file appears over top of the off center tableView, centered correctly but too high (hides behind the navigation bar).

Here's my tableView off-center.

Here's my prototype cell, correctly centered, but too high...and it's a prototype, not my desired content.

I'm using this to reference my nib.

func instanceFromNib() -> UIView {
    return UINib(nibName: "Need", bundle: nil).instantiateWithOwner(nil, options: nil)[0] as UIView

And this is my viewDidAppear where I setup the Subview. (Note, I don't need it centered vertically.)

override func viewDidAppear(animated: Bool) {
    var myView = instanceFromNib()
    self.tableView.addSubview(myView) = CGPointMake(, 0.0)

Because both my tableView and my tableViewCell are in .xib files, I'm getting confused.

Related posts

Recent Viewed