PDA

View Full Version : removing view




schenker
Aug 16, 2011, 02:19 AM
Hi, i have a number of images and buttons in my current view. Instead of removing one at a time, i removed my uiview like so in viewDidDisappear:

[currentView removeFromSuperview];


its saves me so much trouble and it definitely works! but im worried if this is a bad way of doing things. Hope to hear from you guys. Thanks.



jnoxx
Aug 16, 2011, 02:50 AM
in your viewDidDisappear? so your removing it, when your view is already disappearing, I think you're misunderstanding the flow.
In what kind of way would you do this, or need this.
I use removeFromSuperview alot. but not in the viewDidDisappear..

Hope to hear back.

schenker
Aug 16, 2011, 03:18 AM
Thanks for replying. This is what happens:

- this page is actually a level selection game
- at viewWillAppear, it will determine what are the newly unlocked levels and replace the icons with image of an unlocked icon.
-it also has to remove the locked image that's now being unlocked --> This is where the problem begins
- i realise that for the locked image to be completely removed, the uiview has to be refreshed and loadview has to be called again.
- to 'force' loadview' to be called whenever i come to this screen, i removed the view as mentioned in my previous post.

it works, but im a little upset if this is right.

Thanks.


in your viewDidDisappear? so your removing it, when your view is already disappearing, I think you're misunderstanding the flow.
In what kind of way would you do this, or need this.
I use removeFromSuperview alot. but not in the viewDidDisappear..

Hope to hear back.

Hi jnoxx, You are right. I need not do it this way. I fine-tuned my code and it works now even without having to use "viewdiddisappear". Thanks so much, your feedback did help me! :)

jnoxx
Aug 16, 2011, 06:18 AM
That's what were here for Schenker! :)