# Beginning iOS Animations · Animating Constraint Constants | raywenderlich.com

**URL:** <https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029>\
**Category:** 🎓 Courses & Articles\
**Created:** [October 28, 2018, 8:26pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029 "2018-10-28T20:26:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![catie](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/catie/32/110937_2.png) [@catie](https://forums.kodeco.com/u/catie)\
**Post date:** [October 28, 2018, 8:26pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/1 "2018-10-28T20:26:12Z")

</div>

* * *
This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/9051-beginning-ios-animations/lessons/2](https://www.raywenderlich.com/9051-beginning-ios-animations/lessons/2)

---

<div class="post-metadata">

**Author:** ![mazurick](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mazurick/32/81494_2.png) [@mazurick](https://forums.kodeco.com/u/mazurick)\
**Post date:** [November 5, 2018, 3:44pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/2 "2018-11-05T15:44:32Z")

</div>

Hi Catie! How’s it going?

I hope you are well. I have been following this video series. I’m following each instruction and literally pausing the video every ten seconds to make sure I understand each step.

In lesson two after we add the following line I get an error. My animation doesn’t work ☹

menuHeightConstraint.constant = menuIsOpen ? 200 : 80

I’d like to know where I went wrong or if there was a source error contained in the start directory from the resources folder.

I get the following output from my console and an error in the AppDelegate file on line 36

2018-11-05 10:35:20.061618-0500 PackingList[38783:6148120] -[UIView setConstant:]: unrecognized selector sent to instance 0x7fc4dd408750  
2018-11-05 10:35:20.066570-0500 PackingList[38783:6148120] \*\*\* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIView setConstant:]: unrecognized selector sent to instance 0x7fc4dd408750’  
\*\*\* First throw call stack:  
(  
0 CoreFoundation 0x000000010f69629b \_\_exceptionPreprocess + 331  
1 libobjc.A.dylib 0x000000010d4b5735 objc\_exception\_throw + 48  
2 CoreFoundation 0x000000010f6b4fa4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132  
3 UIKitCore 0x0000000113201163 -[UIResponder doesNotRecognizeSelector:] + 287  
4 CoreFoundation 0x000000010f69afb6 _ **forwarding** _ + 1446  
5 CoreFoundation 0x000000010f69ce88 \_CF\_forwarding\_prep\_0 + 120  
6 PackingList 0x000000010cb8618d $S11PackingList14ViewControllerC10toggleMenuyyyXlF + 333  
7 PackingList 0x000000010cb861ec $S11PackingList14ViewControllerC10toggleMenuyyyXlFTo + 60  
8 UIKitCore 0x0000000112e1b7c3 -[UIApplication sendAction:to:from:forEvent:] + 83  
9 UIKitCore 0x0000000112f53e85 -[UIControl sendAction:to:forEvent:] + 67  
10 UIKitCore 0x0000000112f541a2 -[UIControl \_sendActionsForEvents:withEvent:] + 450  
11 UIKitCore 0x0000000112f530e6 -[UIControl touchesEnded:withEvent:] + 583  
12 UIKitCore 0x000000011362e334 -[UIWindow \_sendTouchesForEvent:] + 2729  
13 UIKitCore 0x000000011362fa30 -[UIWindow sendEvent:] + 4080  
14 UIKitCore 0x0000000112e35e10 -[UIApplication sendEvent:] + 352  
15 UIKitCore 0x0000000112d6e0d0 \_\_dispatchPreprocessedEventFromEventQueue + 3024  
16 UIKitCore 0x0000000112d70cf2 \_\_handleEventQueueInternal + 5948  
17 CoreFoundation 0x000000010f5f9b31 **CFRUNLOOP\_IS\_CALLING\_OUT\_TO\_A\_SOURCE0\_PERFORM\_FUNCTION** + 17  
18 CoreFoundation 0x000000010f5f93a3 \_\_CFRunLoopDoSources0 + 243  
19 CoreFoundation 0x000000010f5f3a4f \_\_CFRunLoopRun + 1263  
20 CoreFoundation 0x000000010f5f3221 CFRunLoopRunSpecific + 625  
21 GraphicsServices 0x0000000116fe31dd GSEventRunModal + 62  
22 UIKitCore 0x0000000112e1a115 UIApplicationMain + 140  
23 PackingList 0x000000010cb88dc4 main + 68  
24 libdyld.dylib 0x0000000110b21551 start + 1  
)  
libc++abi.dylib: terminating with uncaught exception of type NSException  
(lldb)

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 5, 2018, 4:51pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/3 "2018-11-05T16:51:47Z")

</div>

@mazurick Make sure you have properly connected your constraint in the storyboard to your `menuHeightConstraint` outlet in the view controller. I hope it helps!

---

<div class="post-metadata">

**Author:** ![mazurick](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mazurick/32/81494_2.png) [@mazurick](https://forums.kodeco.com/u/mazurick)\
**Post date:** [November 5, 2018, 6:42pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/4 "2018-11-05T18:42:15Z")

</div>

Hello @shogunkaramazov!

Thank you! It works!

I found my error too and learned where I was going wrong. I think my error was that I had not correctly selected my constraint for the menus height when I dragged from new referencing outlet to the yellow view controller object and selected menuHeightConstraint.

This really made my day. Until recently I was a rockstar prototyper with Framer. When Framer.js changed to react I found myself confronted with learning a new language just to prototype. I practice swift and Xcode and figured, hey, maybe I can prototype interactions on iOS. So this is my first step towards that goal and it’s looks promising.

---

<div class="post-metadata">

**Author:** ![chuck\_taylor](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chuck_taylor/32/81494_2.png) [@chuck\_taylor](https://forums.kodeco.com/u/chuck_taylor)\
**Post date:** [February 21, 2019, 3:14pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/5 "2019-02-21T15:14:58Z")

</div>

Hi @catie, quick question: How is changing the height constraint on the menu revealing the horizontal slider? I do not see the slider in the interface builder, and the toggleMenu method does not appear to run any additional code for inserting this slider. I know this isn’t the point of the lesson, but I’m hoping you can shed some light on how this was achieved.

---

<div class="post-metadata">

**Author:** ![catie](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/catie/32/110937_2.png) [@catie](https://forums.kodeco.com/u/catie)\
**Post date:** [February 22, 2019, 1:26am UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/6 "2019-02-22T01:26:20Z")

</div>

Hi! Thanks very much for your question. Honestly, I’ve updated this course several times now and each time I’ve reconsidered how much to hide the slider implementation. We’ll see what we can do in the next update to make it less mysterious.

I expect part of the reason it wasn’t easy to find is that the class for the slider is actually called “HorizontalItemList”! You can find it in HorizontalItemList.swift. In ViewController.swift, the `makeSlider()` method is where the slider is actually initialized and added to its parent view. `makeSlider()` is called in `viewDidLoad()`. So, the slider is already added by the time you’re seeing the view controller, but it’s hidden behind the table view. I see you have another question related to this, so I’ll talk more about what I mean by “hidden” there.

If you are wondering how the size or position are determined, take a look at the HorizontalItemList class. You’ll see the convenience initializer uses a predefined CGRect to size and position the slider. The position and height are always the same, but the width varies depending on the view you pass in at initialization.

---

<div class="post-metadata">

**Author:** ![chuck\_taylor](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chuck_taylor/32/81494_2.png) [@chuck\_taylor](https://forums.kodeco.com/u/chuck_taylor)\
**Post date:** [February 22, 2019, 1:48am UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/7 "2019-02-22T01:48:58Z")

</div>

@catie, Thanks for taking the time to explain!

---

<div class="post-metadata">

**Author:** ![smartym\_pro](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/smartym_pro/32/81494_2.png) [@smartym\_pro](https://forums.kodeco.com/u/smartym_pro)\
**Post date:** [October 9, 2019, 8:34pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/8 "2019-10-09T20:34:18Z")

</div>

Thank you! Helpful information for iOS developers.

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [November 14, 2019, 11:37am UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/9 "2019-11-14T11:37:04Z")

</div>

@smartym_pro Really glad you like it! :]

---

<div class="post-metadata">

**Author:** ![andreysvx](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/andreysvx/32/105896_2.png) [@andreysvx](https://forums.kodeco.com/u/andreysvx)\
**Post date:** [January 16, 2020, 10:25am UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/10 "2020-01-16T10:25:33Z")

</div>

@catie, @jessycatterwaul, please describe UIView.animate a bit more detailed:

1. What object does this method belongs to in current application? VIewController or **\_** sender: AnyObject or…?
2. What is view in view.layoutIfNeeded?

Also please explain why does position of view.layoutIfNeeded in toggleMenu() matter?

---

<div class="post-metadata">

**Author:** ![catie](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/catie/32/110937_2.png) [@catie](https://forums.kodeco.com/u/catie)\
**Post date:** [January 25, 2020, 5:01am UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/11 "2020-01-25T05:01:41Z")

</div>

Hi!

1 - It’s a class method on UIView! So, it belongs to the UIView class, and not to a particular object in the application.

2 - `view` is the root view of the ViewController instance.

---

<div class="post-metadata">

**Author:** ![andreysvx](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/andreysvx/32/105896_2.png) [@andreysvx](https://forums.kodeco.com/u/andreysvx)\
**Post date:** [January 28, 2020, 9:21pm UTC](https://forums.kodeco.com/t/beginning-ios-animations-animating-constraint-constants-raywenderlich-com/54029/12 "2020-01-28T21:21:47Z")

</div>

thank you very much! everything is clear now! 🙂
