Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TMS iCL
Initializing controls on multiple forms

When creating an application that manages multiple forms, only the mainform will initialize and display its controls. In this example, the mainform contains an UINavigationController and pushes a UIViewController in view that is placed on a secondary form. Executing the following code, will navigate to the viewcontroller, but the viewcontroller and its children will not be visible / initialized.
TMSFMXNativeUINavigationController1.PushViewController(Form3.TMSFMXNativeUIViewController1,true);
To overcome this, you need to initialize the controls manually by implementing a recursive method InitializeControl:
procedure TForm1.InitializeControl(AControl: TControl);
var
  I: Integer;
begin
  if not Assigned(AControl) then
    Exit;

  if AControl is TTMSFMXNativeUIBaseControl then
  begin
    (AControl as TTMSFMXNativeUIBaseControl).Initialize;
    for I := 0 to AControl.ControlsCount - 1 do
      InitializeControl(AControl.Controls[I]);
  end;
end;
And call the method whenever you need to show a native TMS iCL control that is placed on a form other than the mainform.
procedure TForm1.TMSFMXNativeUIButton1Click(Sender: TObject);
begin
  InitializeControl(SecondaryForm.TMSFMXNativeUIViewController1);
  TMSFMXNativeUINavigationController1.PushViewController(SecondaryForm.TMSFMXNativeUIViewController1,true);
end;