AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Cross-Platform-Entwicklung iOS GUI abhänging vom Target auswählen
Thema durchsuchen
Ansicht
Themen-Optionen

GUI abhänging vom Target auswählen

Ein Thema von Crocotronic · begonnen am 9. Nov 2013 · letzter Beitrag vom 9. Nov 2013
Antwort Antwort
Crocotronic

Registriert seit: 9. Mai 2013
258 Beiträge
 
#1

GUI abhänging vom Target auswählen

  Alt 9. Nov 2013, 13:52
Hallo,
da ich jetzt gerade dabei bin, für meine App eine Oberfläche mit der iCL zu basteln, aber ich trotzdem noch Android unterstützen will, ist mir folgendes eingefallen:
Im Root-Verzeichnis des Projekts liegen die unteren 2 Schichten (Steuerung und Datenerhaltungschicht). In einem weiteren Verzeichnis GUI befinden sich zwei Ordner namens FMX und iOS. Je nach dem, welche Platform ausgewähl wurde, soll der Compiler sich die richtige Oberfläche suchen.
Das sieht im endeffekt so aus:
Delphi-Quellcode:
program Test;

uses
  System.StartUpCopy,
  FMX.Forms,
  {$IFDEF IOS}
  U_MainiOS in 'GUI\iOS\U_MainiOS.pas{F_MainiOS},
  {$ENDIF }
  {$IFDEF ANDROID}
  U_MainFMX in 'GUI\FMX\U_MainFMX.pas{F_MainFMX},
  {$ENDIF }
  {$IFDEF MSWINDOWS}
  U_MainFMX in 'GUI\FMX\U_MainFMX.pas{F_MainFMX},
  {$ENDIF }
  MyData in 'MyData.pas',
  MyControl in 'MyControl.pas',
  Basics in 'Basics.pas';

{$R *.res}

begin
  Application.Initialize;
  Application.FormFactor.Orientations := [TFormOrientation.soInvertedLandscape];
  {$IFDEF IOS}
  Application.CreateForm(TF_MainiOS, F_MainiOS);
  {$ENDIF }
  {$IFDEF ANDROID}
  Application.CreateForm(TF_MainFMX, F_MainFMX);
  {$ENDIF }
  {$IFDEF MSWINDOWS}
  Application.CreateForm(TF_MainFMX, F_MainFMX);
  {$ENDIF }
  Application.Run;
end.
Ich finde die Idee klasse, nur hapert es noch an der Umsetzung.
Unter iOS funtkioniert es, unter Windows und Android läd es keine Obefläche.
Weiß jemand, woran das liegt?

Viele Grüße
Croco

EDIT: Hab mich geirrt . Hab mal alle generierten Dateien gelöscht und schwups hat es funktioniert.

Geändert von Crocotronic ( 9. Nov 2013 um 14:11 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.149 Beiträge
 
Delphi 12 Athens
 
#2

AW: GUI abhänging vom Target auswählen

  Alt 9. Nov 2013, 14:13
Die U_MainFMX wird auch einkompiliert?

Was sagt denn der Debugger?


ach ja
Delphi-Quellcode:
program Test;

uses
  System.StartUpCopy,
  FMX.Forms,
  {$IFDEF IOS}
  U_MainiOS in 'GUI\iOS\U_MainiOS.pas{F_MainiOS},
  {$ELSE}
  U_MainFMX in 'GUI\FMX\U_MainFMX.pas{F_MainFMX},
  {$ENDIF}
  MyData in 'MyData.pas',
  MyControl in 'MyControl.pas',
  Basics in 'Basics.pas';

{$R *.res}

begin
  Application.Initialize;
  Application.FormFactor.Orientations := [TFormOrientation.soInvertedLandscape];
  {$IFDEF IOS}
  Application.CreateForm(TF_MainiOS, F_MainiOS);
  {$ELSE}
  Application.CreateForm(TF_MainFMX, F_MainFMX);
  {$ENDIF}
  Application.Run;
end.
[edit]
Zitat:
Hab mal alle generierten Dateien gelöscht und schwups hat es funktioniert.
"Neu Erzeugen" sollte da auch gehen
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
Benutzerbild von RWarnecke
RWarnecke

Registriert seit: 31. Dez 2004
Ort: Stuttgart
4.408 Beiträge
 
Delphi XE8 Enterprise
 
#3

AW: GUI abhänging vom Target auswählen

  Alt 9. Nov 2013, 16:23
Ich habe das für eine Anwendung so gelöst :
Delphi-Quellcode:
program TestDemo;

uses
  System.StartUpCopy,
  FMX.Forms,
  {$IFDEF IOS}
  iOSapi.UIKit,
  {$ENDIF }
  {$IFDEF ANDROID}
  FMX.Platform.Android,
  Androidapi.JNI.GraphicsContentViewText,
  {$ENDIF }
  PadForm in 'PadForm.pas{PadMainForm},
  PhoneForm in 'PhoneForm.pas{PhoneMainForm},
  CommonHelperUnit in 'units\CommonHelperUnit.pas';

{$R *.res}

////////////////////////////////////////////////////////////////////////////////
///
/// To check if the app is running on an iPad
///
{$IFDEF IOS}
function IsPad: Boolean;
begin
  Result := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice).userInterfaceIdiom = UIUserInterfaceIdiomPad;
end;
{$ENDIF}
{$IFDEF ANDROID}
function IsPad: Boolean;
begin
  Result := (MainActivity.getResources.getConfiguration.screenLayout and TJConfiguration.JavaClass.SCREENLAYOUT_SIZE_MASK)
    >= TJConfiguration.JavaClass.SCREENLAYOUT_SIZE_LARGE;
end;
{$ENDIF}
////////////////////////////////////////////////////////////////////////////////
///
/// Main Program
///
begin
  Application.Initialize;
  Application.FormFactor.Orientations := [TFormOrientation.soPortrait, TFormOrientation.soInvertedPortrait, TFormOrientation.soLandscape, TFormOrientation.soInvertedLandscape];
  if IsPad then
    Application.CreateForm(TPadMainForm, PadMainForm)
  else
    Application.CreateForm(TPhoneMainForm, PhoneMainForm);
  Application.Run;
end.
Rolf Warnecke
App4Mission

Geändert von RWarnecke ( 9. Nov 2013 um 16:28 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:10 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz