Learn about editing constraints in Auto Layout.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3201-auto-layout/lessons/4
Learn about editing constraints in Auto Layout.
I feel like the challenge is 100x harder than the demo. There are a lot things uncovered in the demo like how to make the each image recognize touch, the aspect ratio, and moreā¦ The challenge should be something that was covered in the demo to increase confidence to complete the challenge.
Hi couple of questions
Sorry about that. The challenges are designed to cover the topic from the demoā¦ with a little bit more. If this one was too big of a leap, Iām sorry. I appreciate the feedback and Iāll try to do better in future tutorials.
If you have specific questions, Iām happy to answer those as well. In any case, thanks for helping me make these tutorials better.
Tap Gesture Recognizers can be dragged from the Object library (in the lower right corner of Interface Builder) onto the view they should target.
In the code, the imageTapped
method should act on the appropriate constraint. There are a couple of ways to accomplish this, one would be to have a method for each image and an outlet for each constraint. But in this case, we use a collection and a tag as an index into the collection. The way to make several objects in Interface Builder connect to the same collection is using the āOutlet Collectionā.
Make sure user interaction is enabled (step 5) and make sure the tap gesture is attached to the image and connected to the IBAction.
Thanks, interaction is was off
Hi,
The demo video was useful. Just one suggestion. I have also completed the stack view course. I felt that the idea of covering the solution of challenge in a video is very easy compared to being on a pdf.
Is this something that you would be able to do in future?
Thanks.
sender.view?.tag is 0 irrespective of the imageView i tap on. Iām not sure where iām going wrong. Any suggestions?
Hi, great tutorial thus far. Iām doing the challenge app right now. Iām using Xcode 7.3.1 and when creating the outlet collection for my first constraint everything works well. However, Xcode seemingly does not allow me to attach more constraints to the outlet collection regardless of where on the outlet text I highlight. How can I fix this?
Update: Same with the tapGesture and the associated imageTapped
function. For some reason Iām not able to connect multiple views to one IBAction or IBOutlet.
Update 2: Creating a new sample project Iām able to connect multiple views/tap gesture recognizers to single IBAction/Outlets. I suppose for the challenge app there is something strange going on beneath the hood.
Steps 6-9 have you set the tag of the image views to 1, 2, 3, and 4. Have you set those in Interface Builder? The tag property can be seen on the attributes inspector under the āViewā section.
Hm, Iām not having any issues creating outlets, but I have seen various issues before with Xcode creating outlets. Usually, if I try again it works, or maybe restart Xcode. The other thing you can try is using a different method to create the outlet. The Connections Inspector has circles you can drag or you can right-click on the constraint and drag from āNew Referencing Outlet Collectionā for the constraint or āSelectorā for the gesture recognizer to the View Controller in the view hierarchy and pick the connection.
cant understand how this works.