我想制作没有 nib 文件的 MvxTableViewCell,但我在 stackoverflow、github 和 google 中搜索,我无法手动制作 MvxTableViewCell。
我试过这样的代码,
namespace KittenView.Touch
{
public partial class KittenCell : MvxTableViewCell
{
public static readonly NSString Key = new NSString ("KittenCell");
private readonly MvxImageViewLoader _imageViewLoader;
MonoTouch.UIKit.UIImageView MainImage { get; set; }
MonoTouch.UIKit.UILabel NameLabel { get; set; }
MonoTouch.UIKit.UILabel PriceLabel { get; set; }
public KittenCell () : base ()
{
this.Frame = new RectangleF(0f,0f,100f,120f);
MainImage = new UIImageView (new RectangleF(0f,0f,100f,100f));
NameLabel = new UILabel (new RectangleF (0f, 80f, 100f, 20f));
PriceLabel = new UILabel (new RectangleF (0f, 100f, 100f, 20f));
Add (MainImage);
Add (NameLabel);
Add (PriceLabel);
_imageViewLoader = new MvxImageViewLoader(() => this.MainImage);
this.DelayBind (() => {
var set = this.CreateBindingSet<KittenCell, Kitten>();
set.Bind(NameLabel).To (kitten => kitten.Name);
set.Bind(PriceLabel).To(kitten => kitten.Price);
set.Bind(_imageViewLoader).To (kitten => kitten.ImageUrl);
set.Apply ();
});
this.Transform = CGAffineTransform.MakeRotation ((float)Math.PI / 2.0f);
}
public static KittenCell Create ()
{
return new KittenCell ();
}
}
}
但是这段代码在执行阶段出现异常,说
SetValue:forUndefinedKey:]this calss in not key value coding-compliant for key MainImage。
在 AppDelegate.cs 的 window.MakeKeyAndVisible() 中。
如何在没有 nib 的情况下使用 MvxTableViewCell?
问候,
高黑