nsomar / OAStackView

Porting UIStackView to iOS 7+
MIT License
2.14k stars 200 forks source link

Behavior mismatch between `removeArrangedSubview:` and `removeFromSuperview` #93

Open brunnoferreira opened 7 years ago

brunnoferreira commented 7 years ago

Hey there, @oarrabi!

First of all, thanks for OAStackView and all the effort you put into it. I was just playing with it and replaced a previously iOS 9-only codebase without many issues, but found an odd one.

The original code, which uses UIStackView, follows Apple's guidelines and removes subviews by calling removeFromSuperview. Here's what the docs say about removeArrangedSubview::

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.

OAStackView, on the other hand, seems to expect subviews to be removed by using removeArrangedSubview:, isn't that right? Directly calling removeFromSuperview breaks the constraints system most of the time unfortunately.

I can happily submit a PR with fixes for that if you agree with the changes. I just wanted to make sure the project is still under development first.

Thanks!