Search code examples
iosswiftxcodeswift3xcode11

Storyboard Stack View not connecting to View File (Swift)


I'm using this old tutorial, trying to make a simple red button appear in a horizontal stack view programmatically. I created the StackView file and assigned it to the storyboard stack view's class. I followed the tutorial exactly but the button on the simulator screen and my print to console in the button's file isn't showing. Did linking files to views in Xcode change? Thanks.

Stack View File where the button is made

Storyboard File where stack view's class is assigned to RatingControl file


Solution

  • The problem might be that you are trying to set the buttons before the stack view layout. Try to move the setUpButtons inside the override func layoutSubviews() in the stack view