简体   繁体   English

C#Xamarin Visual Studios使用其他类型的UIView显示UITextField.InputView的信息

[英]C# Xamarin Visual Studios Use different kind of UIView to display information for UITextField.InputView

So I have been able to get a UIPickerView to work with this code. 因此,我已经能够获得一个UIPickerView来使用此代码。 I am able to see the files in a picker when i click the textfield. 单击文本字段时,我可以在选择器中看到文件。

-filesInPath comes from a dropbox connection. -filesInPath来自Dropbox连接。

-AddClassDropboxPathTextBox is a textfield. -AddClassDropboxPathTextBox是一个文本字段。

 public override void ViewDidLoad(){ base.ViewDidLoad(); setupFilePicker(); } public void setupFilePicker(){ PickerModelmodel = new PickerModel(filesInPath); UIPickerView picker = new UIPickerView(); picker.Model = model; UIToolbar pickerToolbar = new UIToolbar(); pickerToolbar.BarStyle = UIBarStyle.Black; pickerToolbar.Translucent = true; pickerToolbar.SizeToFit(); UIBarButtonItem doneButton = new UIBarButtonItem("Choose", UIBarButtonItemStyle.Done, (s, e) => { AddClassDropboxPathTextBox.ResignFirstResponder(); }); pickerToolbar.SetItems(new UIBarButtonItem[] { doneButton }, true); AddClassDropboxPathTextBox.InputView = picker; AddClassDropboxPathTextBox.InputAccessoryView = pickerToolbar; } public class PickerModel : UIPickerViewModel { public List<string> Items { get; private set; } public Int32 SelectedIndex { get; set; } public PickerModelSource(List<String> items) { SelectedIndex = 0; tems = items; } } 

My problem Is I don't want to use a picker. 我的问题是我不想使用选择器。 I want to use a UITableView, so I can allow the user to search through their dropbox file structure. 我想使用UITableView,因此我可以允许用户搜索其保管箱文件结构。 I have tried to replace UIPickerViewModel with a UITableViewSource. 我试图用UITableViewSource替换UIPickerViewModel。 When I click the textfield only the toolbar shows up, and I get no errors. 当我单击文本字段时,仅显示工具栏,并且没有任何错误。

 TableViewSource source = new PTableViewSource(filesInPath); UITableView picker = new UITableView(); picker.Source = source; 

My hope is someone can help me figure out a way to get a UITableView to work instead of UIPickerView. 我希望有人能帮助我找出一种使UITableView代替UIPickerView起作用的方法。

So it turns out that Pickers generally come with a predefined space they take up, while UITableViews do not. 因此,事实证明Pickers通常带有占用的预定义空间,而UITableViews没有。 So a solution is something like this. 因此,解决方案是这样的。 It should be noted that in the size only the y value really matters. 应当指出,在大小上,只有y值才是真正重要的。

 UITableView table = new UITableView(new CoreGraphics.CGRect(new CoreGraphics.CGPoint(0, 0), new CoreGraphics.CGSize(1, 100))); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM