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;

我不需要弹出窗口,因此我阅读了有关通过“hack-ish”方式访问属性和方法的信息

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