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.

Andrew Fakher
Courses Plus Student 1,675 Pointsthe story does't displayed when i press the 'Start your Adventure' button??
override func viewDidLoad() {
super.viewDidLoad()
if let page = page{
artworkView.image = page.story.artWork
let attributedString = NSMutableAttributedString(string: page.story.text)
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 10
attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedString.length))
storyLabel.text = page.story.text
}
override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
view.addSubview(artworkView)
artworkView.translatesAutoresizingMaskIntoConstraints = false // to cannot makes conflict in constraints when the new sub view added
// image constraint
NSLayoutConstraint.activate([
artworkView.topAnchor.constraint(equalTo: view.topAnchor),
artworkView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
artworkView.rightAnchor.constraint(equalTo: view.rightAnchor),
artworkView.leftAnchor.constraint(equalTo: view.leftAnchor)
])
// label constraints
view.addSubview(storyLabel)
storyLabel.numberOfLines = 0
storyLabel.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
storyLabel.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 16.0),
storyLabel.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -16.0),
storyLabel.topAnchor.constraint(equalTo: view.topAnchor, constant: -48.0)
])
}
Marlon Henry
6,885 PointsMarlon Henry
6,885 PointsCan I see the code that you have in the IBaction for when you press the button?
Also
storyLabel.text = page.story.text
sets the value for that label once the view loads, so basically this is the default text for the button as soon as it loads(assuming you're fine with this)