tomvanzummeren / TZStackView

UIStackView replica for iOS 7.x and iOS 8.x
MIT License
1.16k stars 129 forks source link

A way to safely remove a arranged subView #76

Open swapnil-sankla opened 8 years ago

swapnil-sankla commented 8 years ago

The current implementation of removing arrangedSubView is not great because even after removing arranged subView the view is still present. Remove arrangedSubView should work as expected.

A bonus would be if we can remove all the arrangedSubViews together. Some thing like -

@objc func removeAllArrangedSubViews() { for arrangedSubView in arrangedSubviews { removeArrangedSubview(arrangedSubView) arrangedSubView.removeFromSuperview() } updateConstraints() }

andrebraga commented 8 years ago

The official UIStackView does not behave like that.

"This method removes the provided view from the stack’s arrangedSubviews array. The view’s position and size will no longer be managed by the stack view. However, this method does not remove the provided view from the stack’s subviews array; therefore, the view is still displayed as part of the view hierarchy."

warpling commented 8 years ago

Interesting, at least the animation is still preserved!

    [stack removeArrangedSubview:subview];
    [subview removeFromSuperview];
    // Still animates out nicely!