how to programmatically reorder items within a UIStackView in IOS?

心已入冬 提交于 2019-12-06 00:00:34

问题


How can one programmatically reorder items within a UIStackView in IOS?

(i.e. I can not see a function at https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/#//apple_ref/doc/uid/TP40015256-CH1-SW30 to cover this)???


回答1:


surely you can use a combination of

removeArrangedSubview(_:)
insertArrangedSubview(_:atIndex:)

to reorder your views?




回答2:


When adding a view to a parent view, it is automatically removed from it's old parent view.

This is the same with arrangedView, so you only need to use insertArrangedSubview(_:atIndex:) and addArrangedSubview().

Using removeArrangedSubview() is not needed.



来源:https://stackoverflow.com/questions/37717460/how-to-programmatically-reorder-items-within-a-uistackview-in-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!