By adding a subview and then releasing it: “view change that is being completed”,

I have a UIButton named tagButton and a UIScrollView called tagsView.

Inside my method, -(void)renderTagsI do

[[self.tagsView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];

... to clear the decks, I go through a couple of arrays called allTagsand activeTags, alternately creating the “on” and “off” buttons for each tag that the user has ever used in the application. So far, so good. But when I add the newly created UIButton to my view, this way:

[self.tagsView addSubview:tagButton];
[tagButton release];

... for the first time nothing happens in the view, the tag button is not displayed. The second time I put the same line in (which starts -toggleTag, not -createTag, but ends with the same rendering method), I get a console message modifying layer that is being finalized = 0x82b3ec0.

If I comment [tagButton release], everything works. So what gives? I thought adding a subview to the supervisor made the supervisor keep it. I will not deal with this button again, except to say that it will delete itself the next time I create a list of its tags, so it seems that the view controller should release it.

+3
source share
1 answer

, , , tagButton , ... ,

+1

Source: https://habr.com/ru/post/1753886/


All Articles