简体   繁体   中英

iOS 12, issue with UIStackView

I have used UIStackView to create chips which can be removed by the button of delete. It was working fine with iOS 11 as shown below

结果在 iOS 11

But, I am facing an issue of overlapping of Tags in iOS 12 when I tried to remove the chip. The View removed from the list but it remained somewhere and that's why it was displaying like below:

结果在 iOS 12

I tried to investigate and found that Views which I removed were still there in the stack but in the array of arrangedSubviews count was 0

在此处输入图片说明

Can anyone help me in finding the solution for this? or is it the known issue of iOS 12?

The documentation for -[UIStackView removeArrangedSubview:] advises you to remove the formerly arranged view from the UIStackView by invoking removeFromSuperview after removeArrangedSubview: .

In iOS 11 and lower, the view's position was moved off screen when you called -[UIStackView removeArrangedSubview:] and did not removing the formerly arranged view from the UIStackView . Because it was moved away, I personally never noticed the documentation that it should be removed from the superview as well.

In iOS 12, the view is no longer moved offscreen. This enforces that you should follow the documentation's advise to remove the view from the stack view.

https://developer.apple.com/documentation/uikit/uistackview/1616235-removearrangedsubview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM