For example: the first VC entered after starting the APP is the advertising VC. The root view controller at this time is the advertising VC. After a few seconds, it jumps to the homepage VC. At this time, I switch the root view controller to the homepage. VC. Since I no longer need to go back to the advertising VC, I want to release the advertising VC. Is there any way?
Students who have solved this problem will share it.
I tested this situation at the earliest. Such advertising VC will not be released automatically, which means that it always takes up memory, but it is quite small.
You can find the pointer variable of the advertising vc and set it to
nil
. This operation should be performed after the next interface appears to avoid sudden changes in the viewAnother alternative is to manually clear the control pointer in the life cycle method
viewDidDisappear
of the ad vc, such asself.view = nil
, theUIImageView
control of the ad, and because the ad only needs to be loaded once and is large Picture, it is best to use thecontentsOfFile
methodDirectly modify the
rootController
ofWindow
to release the previous advertising VC.