Registriert seit: 15. Mär 2007
4.116 Beiträge
Delphi 12 Athens
|
AW: fmx + TTrackbar + Ios + Taptic Feedback
11. Jun 2023, 09:39
Vielleicht funktioniert das so in der Art bei Dir:
Delphi-Quellcode:
uses
Macapi.ObjectiveC
// Macapi.CoreFoundation
, Macapi.ObjCRuntime
// iOS
, iOSapi.CocoaTypes
, iOSapi.Foundation
;
type
TVibrate_Haptic_Feedback = (Weak, Medium, Strong);
TVibrate_Haptic = class
// Haptic Vibrate feedback generation
// UIImpactFeedbackStyleLight, UIImpactFeedbackStyleMedium, UIImpactFeedbackStyleHeavy
class procedure Execute(const AFeedback : TVibrate_Haptic_Feedback);
end;
implementation
Uses
Macapi.CoreFoundation
;
const
UIImpactFeedbackStyleLight = 0;
{$EXTERNALSYM UIImpactFeedbackStyleLight}
UIImpactFeedbackStyleMedium = 1;
{$EXTERNALSYM UIImpactFeedbackStyleMedium}
UIImpactFeedbackStyleHeavy = 2;
{$EXTERNALSYM UIImpactFeedbackStyleHeavy}
type
UIImpactFeedbackStyle = NSInteger;
UIFeedbackGeneratorClass = interface(NSObjectClass)
['{6B7EC779-C032-4F7A-B51B-BAF0E4249CE6}']
end;
UIFeedbackGenerator = interface(NSObject)
['{5EFF0FE8-F7F1-4443-90B0-94B69C6F9F01}']
procedure prepare; cdecl;
end;
TUIFeedbackGenerator = class(TOCGenericImport<UIFeedbackGeneratorClass, UIFeedbackGenerator>) end;
UIImpactFeedbackGeneratorClass = interface(NSObjectClass)
['{4AD834AB-9CC2-43F2-891B-F0BDD4F03732}']
end;
UIImpactFeedbackGenerator = interface(UIFeedbackGenerator)
['{8BFE603E-FFBC-4109-9AAE-62F77ED4CD57}']
function initWithStyle(style: UIImpactFeedbackStyle): Pointer; cdecl;
procedure impactOccurred; cdecl;
end;
TUIImpactFeedbackGenerator = class(TOCGenericImport<UIImpactFeedbackGeneratorClass, UIImpactFeedbackGenerator>) end;
// Haptic Vibrate generation
// UIImpactFeedbackStyleLight, UIImpactFeedbackStyleMedium, UIImpactFeedbackStyleHeavy
class procedure TVibrate_Haptic.Execute(const AFeedback : TVibrate_Haptic_Feedback);
var
vibrationFeedback: UIImpactFeedbackGenerator;
begin
vibrationFeedback := TUIImpactFeedbackGenerator.Wrap(TUIImpactFeedbackGenerator.OCClass.alloc);
case AFeedback of
Weak : vibrationFeedback.initWithStyle( UIImpactFeedbackStyleLight);
Medium: vibrationFeedback.initWithStyle( UIImpactFeedbackStyleMedium);
Strong: vibrationFeedback.initWithStyle( UIImpactFeedbackStyleHeavy);
else
vibrationFeedback.initWithStyle( UIImpactFeedbackStyleMedium);;
end;
vibrationFeedback.impactOccurred;
end;
Geändert von Rollo62 (12. Jun 2023 um 06:53 Uhr)
|
|
Zitat
|