简体   繁体   中英

how to unload a uiview

I am currently using this if statment to check if a uiview is loaded, this if statment works perfectly..

    if (!myviewName.isViewLoaded) {
         //not loaded so load my view

    }
    else (myviewName.isViewLoaded){
         //is loaded so remove my view (unload)

    }

However when I try to remove the view I dont think I am doing it correctly because I can never enter the first part of that if statement after the first time the view is loaded...

this is the code inside else (myviewName.isViewLoaded){

[myviewName removeFromParentViewController];
   [animatedActionView removeFromSuperview]; 

the reason I use removeFromParentViewController is because I have added myviewName as a subview of animatedActionView, like so

[animatedActionView addSubview:b1VC.view];
[navigationController.view insertSubview:animatedActionView belowSubview:tabbarView];

the animatedActionView is being added as a subview to my navigationcontroller and I am placing it behind my tabbarview which is also a subview on my navigationcontroller..

hopefully this all makes sense.. Just to repeat my question, how do i remove a view so that it will access if (!myviewName.isViewLoaded) { properly.

anyhelp would be appreciated.

UPDATE: As per reply I have been asked to explaine what I am trying to do in more detail which I will do here.

So, my original project has a NavController controlling all of the views I need for the first part of my project (querying the db) the second part of my project is displaying a ton or data.

So I am prototyping my final view in a new project to iron out all the problems I am likely to have, and also hopefully to do it in a way that will not get rejected by apple.

So when I reach the final view of my navController I am loading another navController inside of it. (will this get me rejected?)

this (sub)navController which I will refer to as otherNav will control the final view, it will load several different detailViewController with a special sliding transition animation which the user will be able to slide left and right between detailedViews.

I have also added a tabBar (in its own viewcontroller) as a subview to othernav, when the user transitions between detail views I plan to change the tabBar icons depending on the view, so when the user slide from one detail view to another then the previous icons will fade out and the new icons will fade in.

finally I have several other viewcontrollers which i call actionViews (this is what my question was about) which are loaded/inserted as subviews onto the otherNav but placed behind the tabBar and slide up and down when the tabbar button is selected and deselected.

here is a graphical representation of all of the views and how they sit on the screen.

在此输入图像描述

You need to take care of myViewName's view:

[myViewName.view removeFromSuperview];
myViewName.view = nil;

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