Hay maneras para evitar un
stack overflow:
Usando la ultima forma, porque parece que estas intentando es hacer un 'Navigation Controller` como:
https://developer.apple.com/document...tioncontroller, y es muy fácil de esquematizar:
Código Delphi
[-]
type
TView = (Root, ScreenA, ScreenB);
type
TNavigationStack = class
private
FStack: TArray;
public
constructor Create;
procedure Push(View: TView);
function Pop: TView;
function Current: TView;
end;
constructor TNavigationStack.Create;
begin
SetLength(FStack, 1);
FStack[0] := Root; end;
procedure TNavigationStack.Push(View: TView);
begin
SetLength(FStack, Length(FStack) + 1);
FStack[High(FStack)] := View;
end;
function TNavigationStack.Pop: TView;
begin
if Length(FStack) > 1 then
begin
Result := FStack[High(FStack)];
SetLength(FStack, Length(FStack) - 1);
end
else
Result := Root; end;
function TNavigationStack.Current: TView;
begin
Result := FStack[High(FStack)];
end;