UIStackView : Is it really necessary to call both removeFromSuperView and removeArrangedSubview to remove a subview?

后端 未结 8 924
遥遥无期
遥遥无期 2021-02-02 05:04

From the UIStackView Class Reference

In removeArrangedSubview:

To prevent the view from appearing on screen after calling the stack’s removeArrang

8条回答
  •  时光说笑
    2021-02-02 05:42

    No, just call subview.removeFromSuperview()

    /* Removes a subview from the list of arranged subviews without removing it as
     a subview of the receiver.
        To remove the view as a subview, send it -removeFromSuperview as usual;
     the relevant UIStackView will remove it from its arrangedSubviews list
     automatically.
     */
    open func removeArrangedSubview(_ view: UIView)
    

提交回复
热议问题