Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build an Interactive Story App with Swift 2 Adding Sound Effects Repositioning the Text Field

My solution for the text field, is this fine?

Alright so in the video, Pasan creates another notification for moving the text field back into place.

The way I saw it, we had a textFieldShouldReturn method, and we used the animateWithDuration to move it up, so I just added an animateWithDuration inside of that method and it worked fine. I see nothing wrong with this and it works fine, just wanted to ask if there's anything wrong with doing it this way? The only downside I could see is that you don't have the notification if you are trying to notify multiple objects.

This is what my textFieldShouldReturn looks like:

func textFieldShouldReturn(textField: UITextField) -> Bool {
        textField.resignFirstResponder()

        UIView.animateWithDuration(0.4) {
            self.textFieldBottomConstraint.constant = 40
            self.view.layoutIfNeeded()
        }

        return true
    }