如何在Delphi xe6 for iOS中创建UIPickerView

时间:2014-06-05 20:12:09

标签: delphi delphi-xe6

如何在适用于iOS的Delphi xe6中创建UIPickerview?选择组合框时,会出现UI选择器视图。如何创建类似的选择器视图,但是可以更好地控制它?例如,能够将其放置在表格的任何位置,自定义它,而不必通过组合框等?

我已经在它的单元类中找到了创建它的位置。

FMX.Listbox

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;

App崩溃了。我认为这不是正确的方法。任何帮助或方向将不胜感激!

0 个答案:

没有答案