Sunday, January 12, 2014

UIViewController switching problem

Now there is such a demand:
A switch to B,
B can also be switched to A.
But in the successive switching process will produce a plurality of A and a plurality of B. Cause memory continues to grow.

Problem: How to destroy excess of A and B in excess of the switching process, or in the switching process is not repeated to generate new A and B.


Reply:
The reply was deleted administrator at 2013-10-29 08:49:33

Reply:


1) with Navigation
A push B
B pop A

2) the modal
A present B
B dimiss A

3) with a container viewController
A addChild B
A addChild C
B.. Switching between C see their own definition of it.

I do not know not want the landlord
Reply:
push the recall release
Reply:
View it into two to create displays that do not use that hidden
Reply:
To solve this fucking asked to mention. . Since I write a control UiViewController stack controller. . .
Code is as follows:
 @ interface WindowStack: NSObject {
UIViewController * _root;
NSMutableArray * _stack;
}
- (Id) initWidthRootView: (UIViewController *) root;
- (Void) push: (UIViewController *) controller isClearStack: (BOOL) isClearStack;
- (Void) pop;
@ End

@ Implementation WindowStack
- (Id) initWidthRootView: (UIViewController *) root {
_root = root;
_stack = [[NSMutableArray alloc] initWithCapacity: 5];
[_stack AddObject: root];
return [super init];
}
- (Void) push: (UIViewController *) controller isClearStack: (BOOL) isClearStack {
if (isClearStack) {
while (_stack.count> 1) {
[Self pop];
}
}

[[_stack ObjectAtIndex: _stack.count - 1] presentViewController: controller animated: YES completion: nil];
[_stack AddObject: controller];
}
- (Void) pop {
if (_stack.count> 1) {
UIViewController * controller = [_stack objectAtIndex: _stack.count - 1];
[Controller dismissViewControllerAnimated: NO completion: nil];
[Controller.view removeFromSuperview];
[_stack RemoveObject: controller];
}
}
@ End


I think this is a temporary solution, but it can also be used with ~ ~
Reply:
reference to the third floor h98458 reply: after
push remember release

I use the arc ~ ~
Reply:
reference to the 6th floor meichen8050753 reply:
Quote: references to the third floor h98458 reply:

Remember release

after pushI use the arc ~ ~

If you can correctly use the ARC, you said there should not be a problem
ARC is a program to provide automatic memory management functions at compile time. We have to follow when using one of its basic principles
ARC is a basic principle: as long as an object is either a strong pointer reference, then it will not be destroyed. When the object is not referenced by any strong pointer, then it will be destroyed
Reply:
reference to the 7th floor zhanglei5415 reply:
Quote: references to the 6th floor meichen8050753 reply:

Quote: references to the third floor h98458 reply:

Remember release

after pushI use the arc ~ ~

If you can correctly use the ARC, you said there should not be a problem
ARC is a program to provide automatic memory management functions at compile time. We have to follow when using one of its basic principles
ARC is a basic principle: as long as an object is either a strong pointer reference, then it will not be destroyed. When the object is not referenced by any strong pointer, then it will be destroyed

present time will produce a new UIViewController, while the original is still in the stack being UIViewController, because we can not operate on the stack, so if two UIViewController constantly present, it will cause memory continues to grow.
Reply:
Navigation bar ......... / / / / / / / / / / / / / / / / / / / / / / / / /
Reply:
Why two have been present. . After the present dismiss the right not to return to the previous
Reply:
reference to the 10th floor yang8456211 reply:
Why two have been present. . After the present dismiss that it is not returned before the

UIViewController needs to be pointed out that these two can be switched with each other.
Reply:
reference to the 9th floor u012626125 reply:
navigation bar ......... / / / / / / / / / / / / / / / / / / / / / / / / /

Navigation can not be achieved with switching between two UIViewController it. .
Reply:
reference to the 11th floor meichen8050753 reply:
Quote: references to the 10th floor yang8456211 reply:

Why two have been present. . After the present dismiss that it is not returned before the

UIViewController needs to be pointed out that these two can be switched with each other.


Switching to each other, then put a viewController as container, then add two childController, then transitionFromViewController: toViewController: duration: options: animations: completion: This method is not on it. . .
Reply:
reference to the 13th floor yang8456211 reply:
Quote: references to the 11th floor meichen8050753 reply:

Quote: references to the 10th floor yang8456211 reply:

Why two have been present. . After the present dismiss that it is not returned before the

UIViewController needs to be pointed out that these two can be switched with each other.


Switching to each other, then put a viewController as container, then add two childController, then transitionFromViewController: toViewController: duration: options: animations: completion: This method is not on it. . .

+50 ~
Reply:
reference to the 14th floor meichen8050753 reply:
Quote: references to the 13th floor yang8456211 reply:

Quote: references to the 11th floor meichen8050753 reply:

Quote: references to the 10th floor yang8456211 reply:

Why two have been present. . After the present dismiss that it is not returned before the

UIViewController needs to be pointed out that these two can be switched with each other.


Switching to each other, then put a viewController as container, then add two childController, then transitionFromViewController: toViewController: duration: options: animations: completion: This method is not on it. . .

+50 ~


Hey, but you can also customize a stack, ah, something good to maintain their own extensions
Reply:
reference to the 14th floor meichen8050753 reply:
Quote: references to the 13th floor yang8456211 reply:

Quote: references to the 11th floor meichen8050753 reply:

Quote: references to the 10th floor yang8456211 reply:

Why two have been present. . After the present dismiss that it is not returned before the

UIViewController needs to be pointed out that these two can be switched with each other.


Switching to each other, then put a viewController as container, then add two childController, then transitionFromViewController: toViewController: duration: options: animations: completion: This method is not on it. . .

+50 ~


The landlord of Caesar

No comments:

Post a Comment