Kodeco Forums

Video Tutorial: Introducing Stack Views Part 6: Conclusion

Review what you learned in this series, get a few more tips and tricks for using stack views, and get your final challenge for this video tutorial series.


This is a companion discussion topic for the original entry at http://www.raywenderlich.com/110939/video-tutorial-introducing-stack-views-part-6-conclusion

Hello. I have a problem solving this challenge. No matter how I change distribution of extraDetailStackView (in IB or in code) it always stays the same. As I assume its Fill Equally, at least that’s what I see in IB or even after running in simulator. Am I missing something?

Hi pridumalo,

Sorry you’re having an issue. Do you think you could stick a screenshot in this topic so that I can better understand the problem you’re encountering?

Thanks

sam

The problem is in positioning priceGuideLabel. Although I change distribution, it has no effect on positions of contained labels. Even equal spacing has no effect. The same behaviour with the stack, one step higher in hierarchy. I mean the stack view, which contains Name Label and Extra Detail Stack View. Changing its distribution also don’t seem to have any effect. I double-checked content hugging priority and compression resistance. To be short: Name Label and City Label both have: 250 251 749 750. Everything else has: 251 251 750 750. Except of stack views, which always have 250 250 750 750 (does it really matter? sorry if I missed something from lecture). Thanks in advance for any help!

And one more thing in DetailViewController. I can’t see my mapView, because there is simply not enough room on the screen. Even when I run the finished challenge project in Detail View Controller, my image of pancakes on top of main stack view looks like it has higher vertical priorities than mapView (in fact its opposite), so it shifts it outside the screen. However, in landscape orientation everything works perfectly as expected. It seems like bug in Xcode or some new fix.

Unfortunately this is a change in IB behaviour since I recorded the videos.

I’ve fixed this problem in the past by adding an “Equal Height” constraint between the map and the picture at the top, which would need to be uninstalled for the vertically compact size class. This, combined with ensuring that the outer stack view is no longer 'Fill Equally", but instead just “Fill” for the non-compact vertical size class will allow the map and picture to appear on the screen at the same time.

Hope that helps

sam

Could you clarify the ordering of the priority numbers you’ve sent? Is it CCR:V CCR:H CH:V CH:H?

If that is the case then you need to change the horizontal priorities of either the city label or the price label. At the moment the system doesn’t know which of those two labels to resize.

Hope that helps

sam

I provided priorities exactly in order as it occures in Xcode. Hugging priority: horizontal then vertical. And compression: horizontal and vertical. It means that name label and city label both have less horizontal hugging priority (250 instead of 251) and horizontal compression priority (749 instead of 750) than everything else in stack views. But unfortunately it doesn’t change the positions of the elements. I’ve spend few hours checking for mistakes I probably made, but it seems like a bug. I’ll try to sent screenshot to proof it later. However I’ve mastered solving problems with stack views. That’s great! :]

I’ve created everything from scratch, not just stack views. And it looks like everything works this time. I’ve been trying to find my mistake really hard. Perhaps, it wasn’t the case. Thank you for helping! Finally, I have only one question left. Do we use priorities on stack views? By default it has CHP of 250, and CCR of 750. But does it matter?

Well done for getting to the bottom of the issue :slightly_smiling:

You could use a CHP and CCR on a stack view. For example nested stack views might benefit from their use. But in my experience, more often than not, I haven’t needed to use them.

sam

This was one great of a series! Thank you.

1 Like

I thoroughly enjoyed learning UIStackView. Thanks for this wonderful tutorial series.

1 Like

Cool tutorial - thanks again Sam.

1 Like

Really glad you enjoyed it @gsharm1!

sam