Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Introduction to Table Views Static Table Views for Detail Interfaces Table View Headers

Rea Rahhal
PLUS
Rea Rahhal
Courses Plus Student 4,732 Points

cannot display the images next to the contact and in the detail controller

I am 100% sure about my code and I have added the images but cannot display them ...

here its my code:

import UIKit

class ContactDetailController: UITableViewController {


    var contact: Contact?////checking if we have a contact associated with the controller

    //outlets

    @IBOutlet weak var profileView: UIImageView!
    @IBOutlet weak var phoneNumberLabel: UILabel!

    @IBOutlet weak var emailLabel: UILabel!

    @IBOutlet weak var nameLabel: UILabel!

    @IBOutlet weak var StreetAddressLabel: UILabel!


    @IBOutlet weak var cityLabel: UILabel!


    override func viewDidLoad() {
        super.viewDidLoad()
configureViews()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

//Configure View method to set up labels .Called when the view loads
    func configureViews(){
        //contact property is an optional so we unwrap it
        guard let contact = contact else {return}
        phoneNumberLabel.text = contact.phone
        emailLabel.text = contact.email
        StreetAddressLabel.text = contact.street
        cityLabel.text = contact.city
        profileView.image = contact.image
        nameLabel.text = "\(contact.firstName) \(contact.lastName)"//string interpolation to display first name and last name 

    }
}
Jhoan Arango
Jhoan Arango
14,522 Points

Hello,

Would you mind sharing your code on here ? It will help us to see what may have gone wrong.

Its back-sticks, not single quotes okay. Remember that when you share your code, got it?

1 Answer

Jhoan Arango
Jhoan Arango
14,522 Points

Based on your code, this should work. Unfortunately for me, I can't see the rest of your set up, so it's difficult for me to say what is wrong, but here are some things you may want to keep in mind.

Make sure your User Model has the proper properties set up, also make sure you have the "Pictures" in your assets files, to double check, disconnect your outlets, and reconnect them. Those are a few things you can do to check that everything is working fine.

If you need me to look into your project and you are familiar with GitHub, you should upload it there so that I can have a look.

Another Tip is, keep your code organized: For example

If you have properties in a specific order, make sure you give them their values in the same order.

Property 1
Property 2
Property 3

func configureView() {

property 1 = value
property 2 = value
property 3 = value

}

Maybe even that can be one of your problems, organize it and give it a try.