AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Cross-Platform-Entwicklung iOS iOS: AnimationDelegate: Events richtig hinzufügen???

iOS: AnimationDelegate: Events richtig hinzufügen???

Ein Thema von romber · begonnen am 9. Jul 2014
Antwort Antwort
romber

Registriert seit: 15. Apr 2004
Ort: Köln
1.164 Beiträge
 
Delphi 10 Seattle Professional
 
#1

iOS: AnimationDelegate: Events richtig hinzufügen???

  Alt 9. Jul 2014, 20:33
Hallo!

Ich versuche einer Animation zwei Events für BeginAnimation- und EndAnimation hinzu zu fügen. Auf dem Gerät klappt alles wunderbar, nur im Simulator sturzt die App ab. Hier der Code:

Delphi-Quellcode:
type
  id = Pointer;
  SEL = Pointer;
  PNSString = Pointer;
  PNSNumber = Pointer;

type
  TMenuEndAnimationType = (maNone, maOpen, maClose);

var
  frmMain: TfrmMain;
  animationDelegateClass: Pointer;
  statusBarView: UIView;
  oldPositionX, newPositionX: Single;
  ...

procedure TfrmMain.FormCreate(Sender: TObject);
begin
   ...
  //Hier wird AnimationDelegate initialisiert
  animationDelegateClass := objc_allocateClassPair(objc_getClass('NSObject'), 'DelphiAnimationDelegate', 0);
  class_addMethod(animationDelegateClass, sel_getUid('openMenuAnimationDidStop:finished:context:'), @openMenuAnimationDidStop, 'v@:@@@');
  class_addMethod(animationDelegateClass, sel_getUid('closeMenuAnimationDidStop:finished:context:'), @closeMenuAnimationDidStop, 'v@:@@@');
  class_addMethod(animationDelegateClass, sel_getUid('statusBarAnimationSelector:context:'), @statusBarAnimationSelector, 'v@:@@');
  objc_registerClassPair(animationDelegateClass);
  ...
end;

//Hier die neuen Methoden
procedure openMenuAnimationDidStop(self: id; _cmd: SEL; animationID: PNSString; finished: PNSNumber; context: CGContextRef);
begin
  statusBarView.setAlpha(1);
  TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication).setStatusBarStyle(UIStatusBarStyleLightContent, false);
end;

procedure closeMenuAnimationDidStop(self: id; _cmd: SEL; animationID: PNSString; finished: PNSNumber; context: CGContextRef);
begin
  statusBarView.setAlpha(0);
  TUIApplication.Wrap(TUIApplication.OCClass.sharedApplication).setStatusBarStyle(UIStatusBarStyleDefault, false);
end;

procedure statusBarAnimationSelector(self: id; _cmd: SEL; animationID: PNSString; context: CGContextRef);
begin
  TUIView.OCClass.beginAnimations(nil, nil);
  TUIView.OCClass.setAnimationDuration(0.2);
  statusBarView.setAlpha(oldPositionX / 1.7 * 0.01);
  statusBarView.setAlpha(newPositionX / 1.7 * 0.01);
  TUIView.OCClass.commitAnimations;
end;

//Und hier liegt das Problem
procedure TfrmMain.OpenCloseMenu(const X_From, X_To, Y_From, Y_To: Single; const W_From, W_To, H_From, H_To, AAnimationDuration: Extended; AEndAnimation: TMenuEndAnimationType = maNone);
begin
  oldPositionX := X_From;
  newPositionX := X_To;

  TUIView.OCClass.beginAnimations(nil, nil);
  TUIView.OCClass.setAnimationDuration(AAnimationDuration);
  TUIView.OCClass.setAnimationDelegate(@animationDelegateClass);
  TUIView.OCClass.setAnimationWillStartSelector(Sel_getUid('statusBarAnimationSelector:context:')); // <---Hier stürzt der Simulator ab
  case AEndAnimation of
    maOpen: TUIView.OCClass.setAnimationDidStopSelector(Sel_getUid('openMenuAnimationDidStop:finished:context:')); // <---oder hier
    maClose: TUIView.OCClass.setAnimationDidStopSelector(Sel_getUid('closeMenuAnimationDidStop:finished:context:')); // <---oder hier
  end;
  ApplicationView.FUIViewController.view.setFrame(CGRectMake(X_From, Y_From, W_From, H_From));
  ApplicationView.FUIViewController.view.setFrame(CGRectMake(X_To, Y_To, W_To, H_To));
  TUIView.OCClass.commitAnimations;
end;
Das Problem liegt definitiv an der Code, mit dem ich der UIView-Classe die Events hinzufüge:

Delphi-Quellcode:
TUIView.OCClass.setAnimationWillStartSelector(Sel_getUid('statusBarAnimationSelector:context:'));
TUIView.OCClass.setAnimationDidStopSelector(Sel_getUid('openMenuAnimationDidStop:finished:context:'));
TUIView.OCClass.setAnimationDidStopSelector(Sel_getUid('closeMenuAnimationDidStop:finished:context:'));
Was mache ich falsch?

Geändert von romber ( 9. Jul 2014 um 20:35 Uhr)
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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 07:27 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