4

I am loading a UITableViewController, and I have the following:

override func viewWillAppear(animated: Bool) {
    nameCell.detailTextLabel?.text = ApplicationUser.sharedInstance.profile.getFullName()!
}

If I println(nameCell.detailTextLabel?.text) after making the above call, the value is set correctly. On first display of the screen the value does not show, however if I navigate to a detail view and then come back to this screen, the value is displayed as expected. Why?

I am simulating iPhone 5s.

David Poxon
  • 2,435
  • 4
  • 23
  • 44

2 Answers2

1

In IB, I had originally set the detailTextLabel to "" or blank. To fix this problem, I set placeholder text in IB and the label was populated on the view appearing.

Setting the label to " " was enough.

David Poxon
  • 2,435
  • 4
  • 23
  • 44
1

I had the same problem. setting the prototype cell style to 'Subtitle' solved the problem. My experience if we don't set the style assigning text to detailedTextlabel doesn't work. 1.Select prototype cell 2.Go to 'Attributes inspector', set style to 'Subtitle' (XCode 6.3) Example:

cell.textLabel?.text = self.vendorDetails[indexPath.row].vendorName
cell.detailTextLabel?.text = vendorAddress

Hope this is useful

Murthy Rao
  • 11
  • 3