1

Delphi xe6 for iOS で UIPickerview を作成するにはどうすればよいですか? コンボボックスを選択すると、UI ピッカー ビューが表示されます。同様のピッカービューを作成するにはどうすればよいですか? たとえば、フォームのどこにでも配置できる、カスタマイズできる、コンボボックスを経由する必要がないなど。

それが作成されたユニットクラスの場所を見つけました。

FMX.リストボックス

constructor TCustomComboBox.Create(AOwner: TComponent);
var
  PickerService: IFMXPickerService;
begin
  inherited;
  if TPlatformServices.Current.SupportsPlatformService(IFMXPickerService, IInterface(PickerService)) then
  begin
    FListPicker := PickerService.CreateListPicker;
    FListPicker.Parent := Self;
    FListPicker.OnValueChanged := DoOnValueChangedFromDropDownList;
    FListPicker.OnHide := DoClosePicker;
    FListPicker.OnShow := DoPopup;
  end;
  FDropDownKind := TDropDownKind.Custom;
  DropDownCount := 8;
  FItemWidth := 0;
  CanFocus := True;
  FDroppedDown := False;
  FPopup := TPopup.Create(Self);
  FPopup.StyleLookup := 'combopopupstyle';
  FPopup.PlacementTarget := Self;
  FPopup.Stored := False;
  FPopup.Parent := Self;
  FPopup.Locked := True;
  FPopup.DesignVisible := False;
  FPopup.DragWithParent := True;
  FPopup.OnClosePopup := DoClosePopup;
  FPopup.OnPopup := DoPopup;
  FListBox := CreateListBox;
  FListBox.Parent := Popup;
  FListBox.Stored := False;
  FListBox.Align := TAlignLayout.Client;
  FListBox.ShowCheckboxes := False;
  FItemIndex := -1;
  SetAcceptsControls(False);
  DropDownKind := TDropDownKind.Native;
end;

ポップアップは必要ないので、「ハックっぽい」方法でプロパティとメソッドにアクセスする方法について読みます

Type
  THackPicker = class(TCustomComboBox);

....

var
  FListBox : TComboListBox;
begin
    try
      FListBox := THackPicker(FListBox).createListbox;
      FListBox := TCustomComboBox.createListbox;
      FListBox.Parent := Layout1;
      FListBox.Stored := False;
      FListBox.Align := TAlignLayout.Client;
      FListBox.Items := ComboBox1.Items;
      FListBox.OnClick := Button2Click;
    except
        on E : Exception do begin
          showMessage(e.Message);
        end;

    end;
end;

ここでアプリがクラッシュします。これは正しい方法ではないと思います。どんな助けや指示も大歓迎です!

4

0 に答える 0