iPad で Xamarin モノタッチ アプリを実行すると、UIPickerView が表示されますが、空です。どのデリゲートも起動しません: GetRowsInComponent GetComponentCount GetTitle
ストーリーボードで UIPickerView を作成し、ファイルの所有者に接続しました。
ここに私の.csコードがあります.................
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
namespace MainApp
{
public partial class Ultrasound_Controller : UIViewController
{
public Ultrasound_Controller(IntPtr handle)
: base(handle)
{
}
Presets_File_Picker_Model presets_file_picker_model;
public override void ViewDidLoad()
{
Console.WriteLine("ViewDidLoad");
base.ViewDidLoad();
}
public class Presets_File_Picker_Model : UIPickerViewModel
{
public event EventHandler<EventArgs> ValueChanged;
/// <summary>
/// The color we wish to display
/// </summary>
public List<string> Items
{
get { return items; }
set { items = value; }
}
List<string> items = new List<string>();
/// <summary>
/// The current selected item
/// </summary>
public string SelectedItem
{
get { return items[selectedIndex]; }
}
protected int selectedIndex = 0;
/// <summary>
/// default constructor
/// </summary>
public Presets_File_Picker_Model()
{
}
public override int GetRowsInComponent(UIPickerView picker, int component)
{
Console.WriteLine("GetRowsInComponent");
return 5;
}
public override int GetComponentCount(UIPickerView picker)
{
Console.WriteLine("GetComponentCount");
return 1;
}
public override string GetTitle(UIPickerView picker, int row, int component)
{
Console.WriteLine("GetTitle");
return "Component " + row.ToString();
}
/// <summary>
/// called when a row is selected in the spinner
/// </summary>
public override void Selected (UIPickerView picker, int row, int component)
{
Console.WriteLine("Selected");
selectedIndex = row;
if (this.ValueChanged != null)
{
this.ValueChanged (this, new EventArgs ());
}
}
}