Menu

How to do TForm.Show() has a Animation switch?

Johnson
2014-03-05
2014-03-08
  • Johnson

    Johnson - 2014-03-05

    I hope from A form switch to B form has a animation same as NavigatorController.PushViewController() .
    how to do this?

    sorry to my poor english.

     
  • Fenistil

    Fenistil - 2014-03-05

    Hi!

    Please check the FormWrapSlideTransition Demo!

    Greetings

     
  • Johnson

    Johnson - 2014-03-05

    Yeah, it create two view special for animation, that is complex, is not a good solution for a lot of forms.
    I means that one ViewController split a unit like as xcode UIViewController , and NavController can push or pop viewcontroller.

    I see all demo, I found all UI Viewcontrollers must be in a form ( TDPFNavigationController, TDPFUIPageViewController), means a lot of codes must be in one unit, and be created while running, whether or not be used.
    I know has a form/frame properity to split other unit, but it's difficultly to communication with NavigationController.

    Has anybody a good advise?

     
  • Fenistil

    Fenistil - 2014-03-05

    Create a MainForm, this should be a TForm. Put a NavController on it, add some page, and do not put anything on any page. Now create a TFrame for each page. For example, your NavController has PageA, PageB and PageC, then create FrameA, FrameB and FrameC. Design your frames and put their code to their unit. You can create a global helper unit to hold the Frames' variables.

    unit Globals;
    
    uses Unit_FrameA, Unit_FrameB, Unit_FrameC;
    
    var 
      FrameA:TFrameA;
      FrameB:TFrameB; 
      FrameC:TFrameC;
    

    Now in your main form's OnShow do this:

    uses Unit_FrameA, Unit_FrameB, Unit_FrameC, Globals;
    
    PageA.Frame:=TFrameA;
    FrameA:=PageA.GetFrame;
    PageB.Frame:=TFrameB;
    FrameB:=PageB.GetFrame;
    PageC.Frame:=TFrameC;
    FrameC:=PageC.GetFrame;
    

    If you have to do something with any of your page outside of its own unit, just do this:

    uses Globals;
    
    FrameA.Label1.Text:='Hello from PageA!';
    

    After you have set up this, you can easily call NavController.PushViewController or PopViewController.
    Don't forget to set the PageIndex to 0 on the page you want to be the first.

    By this, every page has its on unit, you don't have to put everything in one form. On the other hand, Frames are faster to load and consume less memory, so try to use them istead of Forms.

    I hope it helps.

    Greetings

    PS.: I wrote it from mind, I don't have here Delphi now, maybe you can find some mistakes. If yes, report it, and I'll check it.

     

    Last edit: Fenistil 2014-03-05
  • Johnson

    Johnson - 2014-03-08

    thanks Fenistil. that is good.
    I think better method, page design split to another unit, create on demand. register TDPFNavigationControllerPage as a component:

    edit DPF.iOS.Reg.pas,
    procedure Register;
    begin
    RegisterComponents(.., [.., TDPFNavigationControllerPage, ..]);
    ...
    end;

    how to use?
    a unit include frame, add TDPFNavigationControllerPage to this frame, coding...

    in main form,
    var
    NavController: TDPFNavigationController;
    Frame1: TFrame1;

    Frame1:= TFrame1.Create(self);
    NavController.PageIndex:= NavController.Count; // if no this line, will raise error
    Frame1.NavigationControllerPage.Parent:= NavController;
    Frame1.NavigationControllerPage.Loaded;

    but has a bug, the bar buttons of TDPFNavigationControllerPage not be displayed.

     

    Last edit: Johnson 2014-03-08

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.