I have a little pickle here. Create an iOS game that contains two views: BaseView and MapView. Now they, of course, have the same appDelegate.
In both cases, a subclass of UIView called rivbox is used . In previous builds, I highlighted an rivbox instance in both Base and Map-view. When I realized that I would have many subheadings using this rivbox, I decided instead to select only one instance of rivbox in appDelegate, and then when the preview is loaded, I can "borrow" rivbox from appDelegate using these great features.
-(void)viewDidLoad {
And this function is intended to update the owner, if we return to this view again
-(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if(rivbox != nil) { [rivbox setDelegate:self]; [self.view addSubview:rivbox]; } }
It's fine! I find rivbox in appDelegate and it is updated! When I switch to another view, it loads there too just fine! But when I return to the first view, it seems to be a leak?!?! I do not see rivbox in my previous view when I return to it, although the previous view now belongs to it!
Problem: what's wrong with this? Should I really add rivbox as a subview every time I return to an already loaded view? If I delete this line, I cannot see MyBox when I return to the previous view.
source share