unit TestVieweriOS;
interface
uses
SysUtils, DateUtils, Classes, System.Types, System.UITypes, Generics.Collections,
iOSapi.UIKit, iOSapi.Foundation, iOSapi.CocoaTypes, iOSapi.CoreGraphics,
MacApi.ObjectiveC, MacApi.ObjcRuntime,
FMX.Types, FMX.TMSNativeUIScrollView, FMX.Dialogs, FMX.TMSNativeUIButton,
FMX.TMSNativeUIViewController, FMX.TMSNativeUIPageViewController,
FMX.TMSNativeUIBaseControl, FMX.TMSNativeUIView, FMX.TMSNativeUILabel,
Interfaces.VPlanController.VPlanViewer;
type
TViewerElement =
class(TTMSFMXNativeUIViewController)
private
FContainer: TTMSFMXNativeUIScrollView;
procedure Clear;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
end;
type
TTestViewer =
class(TTMSFMXNativeUIView)
private
FPager: TTMSFMXNativeUIPageViewController;
FViewElements:
array[0..4]
of TViewerElement;
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
end;
implementation
{ TTestViewer }
constructor TTestViewer.Create(AOwner: TComponent);
var n: Integer;
begin
inherited;
FPager:= TTMSFMXNativeUIPageViewController.Create(Self);
FPager.Parent:= Self;
FPager.Align:= TAlignLayout.alClient;
for n:= Low(FViewElements)
to High(FViewElements)
do
begin
FViewElements[n]:= TViewerElement.Create(FPager);
with FViewElements[n]
do
begin
Parent:= FPager;
Align:= TAlignLayout.alClient;
Initialize;
end;
FPager.Pages.Add.View:= FViewElements[n];
end;
FPager.Initialize;
end;
destructor TTestViewer.Destroy;
var n: Integer;
begin
for n:= Low(FViewElements)
to High(FViewElements)
do
FViewElements[n].DisposeOf;
FPager.DisposeOf;
inherited;
end;
{ TViewerElement }
constructor TViewerElement.Create(AOwner: TComponent);
begin
inherited;
// ----------- PROBLEM ----------- //
FContainer:= TTMSFMXNativeUIScrollView.Create(Self);
with FContainer
do
begin
Parent:= Self;
Align:= TAlignLayout.alClient;
ScrollView.setContentSize(CGSizeMake(FWidth,FHeight));
Margins.Top:= CONTAINER_MARGIN_TOP;
Initialize;
end;
// ------------------------------ //
end;
destructor TViewerElement.Destroy;
begin
FContainer.DisposeOf;
inherited;
end;
procedure TViewerElement.Clear;
begin
FContainer.ScrollView.subviews.makeObjectsPerformSelector(sel_getUid('
removeFromSuperview'));
end;
end.