MediaLibrary Delphi类型转换错误
问题描述:
我在Delphi上遇到MediaLibrary问题。MediaLibrary Delphi类型转换错误
我让下面这段代码我的主要形式:
unit uPrincipal;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes,
System.Variants,FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics,
FMX.Dialogs,
FMX.Controls.Presentation, FMX.MultiView, FMX.Objects, FMX.Layouts,
FMX.StdCtrls, System.Actions, FMX.ActnList, FMX.StdActns,
FMX.MediaLibrary.Actions, FMX.MediaLibrary, FMX.Platform, System.Messaging;
type
TfmPrincipal = class(TForm)
Layout1: TLayout;
mvMenu: TMultiView;
rctMenuPrincipal: TRectangle;
rctMenuTop: TRectangle;
rctMenuBody: TRectangle;
rctOpHome: TRectangle;
rctBodyPrincipal: TRectangle;
tbPrincipal: TToolBar;
StyleBook1: TStyleBook;
sbMenu: TSpeedButton;
sbPhoto: TSpeedButton;
ActionList1: TActionList;
TakePhotoFromLibraryAction1: TTakePhotoFromLibraryAction;
Image1: TImage;
TakePhotoFromCameraAction1: TTakePhotoFromCameraAction;
procedure TakePhotoFromLibraryAction1DidFinishTaking(Image: TBitmap);
private
{ Private declarations }
public
{ Public declarations }
end;
var
fmPrincipal: TfmPrincipal;
implementation
{$R *.fmx}
{$R *.LgXhdpiPh.fmx ANDROID}
{$R *.NmXhdpiPh.fmx ANDROID}
{$R *.iPhone.fmx IOS}
uses uLogin, uTeste;
procedure TfmPrincipal.TakePhotoFromLibraryAction1DidFinishTaking(
Image: TBitmap);
begin
Image1.Bitmap.Assign(Image);
end;
end.
当我我的手机上运行此,我点击SpeedButton的,我收到一个“无效类类型转换”的错误消息。
我在TActionList
中加入了TakePhotoFromLibraryAction1
,并将它设置为速度按钮的Action
。
我不知道为什么我得到这个错误。
答
这是您的Delphi版本中的一个错误。
一种解决方法是使用TButton
而不是TSpeedButton
。
另一个解决方法是,以除去从SpeedButton的所述Action
分配,然后使用该按钮的OnClick
事件来调用该操作的ExecuteTarget()
方法,传递不同的控制作为Target
参数。