MediaLibrary Delphi类型转换错误

时间:2017-08-14 03:46:38

标签: delphi firemonkey delphi-10.1-berlin

我在Delphi上的MediaLibrary有问题。

我在主表单上创建了以下代码:

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,我收到一个"无效的类别类型"错误信息。

我在TakePhotoFromLibraryAction1中添加了TActionList,并将其设置为SpeedButton的Action

我不知道为什么会收到此错误。

1 个答案:

答案 0 :(得分:2)

这是您的Delphi版本中的错误。

一种解决方法是使用TButton而不是TSpeedButton

另一种解决方法是从SpeedButton中删除Action分配,然后使用按钮的OnClick事件来调用操作ExecuteTarget()方法,并通过它与Target参数不同。