I have a UITableViewCell
with three labels on it. Two along the top and one that holds some content along the bottom. I constrain the two top labels so that they are 8pts from the top of the view. The left label is 8pts from the leading edge and the right label is 8pts from the trailing edge. I then set the left label to be 12pts minimum from the right label.
Title constraints
Date constraints
It looks fine in Xcode when I evaluate it. I can add a really long title (left topmost label) and it truncates the text correctly, giving me my 12pt margin to the date label.
When I run the app at runtime, the constraints don't seem to be applied. The title label is the full width of the device with the date label no where to be seen.
It does this on the iPhone 5, 5s, 6 and 6 Plus simulators. What am I doing wrong? In my viewDidLoad()
method, I am loading the nib containing the UITableViewCell
and then registering it. I also add a button to the UINavigationController
.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem()
if let split = self.splitViewController {
let controllers = split.viewControllers
self.detailViewController = controllers[controllers.count-1].topViewController as? DetailViewController
}
// Register our additional nibs
let nibName = UINib(nibName: "StandardNoteCell", bundle: nil)
tableView.registerNib(nibName, forCellReuseIdentifier: identifier)
self.newNoteButton = self.createNewRoundButton()
self.navigationController?.view.addSubview(self.newNoteButton)
}
Does anything stand out as being incorrect?