简体   繁体   中英

How to remove a view from superview, without reloading?

I have a game, and i want to remove an obstacle. But when i do this, the view is completely refreshing itself. But I want the other subviews to stay, where they where.

To remove this subview I use:

obstacles.removeFromSuperview()

Then it disappears on the screen, but after that all other subviews are set to their original Position..

is there another method, or do i have to save the positions and after reloading set it back again? wouldn't that look bad and buggy?

Btw, when i added my view to subview, it was a let. don't know if its important..

If the other subviews move it means that their position depends on the view you removed. Working with auto layout take into account that removeFromSuperview removes any constraints that refer to the view you are removing (or to its children).

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