Monday, December 16, 2013

How release subviews?

I created a new view1 in view, and then how should we deal with view1 after addsubview?

CustomViewController * customViewController = [[CustomViewController alloc] initWithNibName: @ "CustomViewController"];
[Self.view addsubview: customViewController.view];
[CustomViewController release];

Above: if I release customViewController self.view will be displayed above the top toolbar is only one jump a customViewController.view display. But if I do not release it, it will be a memory leak. How to handle this.
I Useful [[[CustomViewController alloc] initWithNibName] autorelease] behind release effect is the same.
Seek expert advice good solution, best explain the specific reasons, be grateful.
Reply:
The reply was deleted at the moderator 2011-08-22 10:36:03

Reply:
"A jump customViewController.view top toolbar display," What does this mean?
Reply:
With removeFromSuperview
Reply:
A jump customViewController.view top toolbar is displayed, "What does this mean?
customViewController.view There toolbar, and then lost it in the back of release, the final result will be displayed only shows customViewController.view the toolbar, the other did not show up.
Reply:
3rd Floor, positive solution.

But your [customViewController] is local, you need time to create either create a class variable, or saved when created, keep [removeFromSuperview] when used.
Reply:
We are held by UIViewController View are not going to deal with.
Reply:
The reply was deleted at the moderator 2011-11-07 10:40:54

Reply:
customViewController when it is not until the release, otherwise you can not control your view.
Reply:
Are generally not in the inside release of. . . Should be a memory leak it elsewhere
Reply:
Already figured out, Ha ha ha

No comments:

Post a Comment