简体   繁体   English

如何卸载uiview

[英]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 if statment来检查是否加载了uiview,如果这个判断工作正常的话......

    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... 但是,当我尝试删除视图时,我不认为我正确地执行它,因为在第一次加载视图后,我永远无法输入if语句的第一部分...

this is the code inside else (myviewName.isViewLoaded){ 这是其他内部的代码(myviewName.isViewLoaded){

[myviewName removeFromParentViewController];
   [animatedActionView removeFromSuperview]; 

the reason I use removeFromParentViewController is because I have added myviewName as a subview of animatedActionView, like so 我使用removeFromParentViewController的原因是因为我已经将myviewName添加为animatedActionView的子视图,就像这样

[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.. animatedActionView作为子视图添加到我的navigationcontroller中,我将它放在我的tabbarview后面,这也是我的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. 希望这一切都有意义..只是重复我的问题,我如何删除一个视图,以便它将访问if(!myviewName.isViewLoaded){正确。

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. 所以,我的原始项目有一个NavController控制我项目第一部分所需的所有视图(查询数据库)我的项目的第二部分是显示吨或数据。

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. 因此,当我到达navController的最终视图时,我正在其中加载另一个navController。 (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. 这个(sub)navController我将其称为otherNav将控制最终视图,它将加载几个不同的detailViewController,其中包含一个特殊的滑动过渡动画,用户可以在详细视图之间左右滑动。

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. 我还添加了一个tabBar(在它自己的viewcontroller中)作为othernav的子视图,当用户在详细视图之间切换时我计划根据视图更改tabBar图标,因此当用户从一个细节视图滑动到另一个细节视图时之前的图标将淡出,新图标将淡入。

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. 最后我有几个其他的viewcontrollers我称之为actionViews(这是我的问题所在),它们作为子视图加载/插入到otherNav上,但放在tabBar后面,并在选择和取消选择tabbar按钮时上下滑动。

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的视图:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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