UIStackView does not resize after display

I am new to the stack, but I try to hide and show the block of nested subzones using the button in the parallel stack view. Hiding works (viewing the target stack is reduced to one row and quits), but when I try to show, the view of the nested stack (actually a stack of rows, each of which is a stack of columns) does not expand again. I just get one line. Code below

import UIKit

class Grid: UIViewController {

    @IBOutlet weak var mainGrid: UIStackView!

    @IBAction func examplesPressed(sender: AnyObject) {

        UIView.animateWithDuration(0.8, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 10.0, options: UIViewAnimationOptions(), animations: { () -> Void in
            self.mainGrid.hidden =  !self.mainGrid.hidden
            }, completion: nil)

    }
}

with the image before the hide operation (click example)

before hiding

and what I get when I try to show

after trying to show

What am I missing here?

+4
source share

Source: https://habr.com/ru/post/1615879/


All Articles