我正在尝试在用Xamarin和MvvmCross构建的iPhone应用程序中显示MvxCollectionViewCell的背景图像。我针对iOS 6.0及更高版本。以下是我正在使用的代码。我在获取背景图片时遇到了一些问题。我似乎无法弄清楚我做错了什么。似乎它应该相当简单。我在XCode中创建了单元格。单元格为100 X 100.它包含一个单独的UIImageView,它是90 X 72. UIImageView的X和Y分别是5和8。我也无法让图像在单元格内调整大小,但计划很快发布另一个问题。MvxCollectionViewCell的显示背景
using MonoTouch.UIKit;
using Cirrious.MvvmCross.Binding.Touch.Views;
using Cirrious.MvvmCross.Binding.BindingContext;
namespace DriveThroughSafari.Touch.Views.Pictures
{
public sealed partial class AnimalCutoutCell : MvxCollectionViewCell
{
public static readonly UINib Nib = UINib.FromName ("AnimalCutoutCell", NSBundle.MainBundle);
public static readonly NSString Key = new NSString ("AnimalCutoutCell");
private readonly MvxImageViewLoader _loader;
public AnimalCutoutCell (IntPtr handle) : base (handle)
{
MainImage = new UIImageView();
_loader = new MvxImageViewLoader(() => MainImage);
BackgroundView = new UIImageView {Image = new UIImage("Images/photo-frame")};
this.DelayBind(() =>
{
var set = this.CreateBindingSet<AnimalCutoutCell, AnimalDataViewModel>();
set.Bind(_loader).To(animal => animal.ImageUrl);
set.Apply();
});
}
public static AnimalCutoutCell Create()
{
return (AnimalCutoutCell)Nib.Instantiate (null, null) [0];
}
}
}
我很感谢帮助!
这可能是因为当笔尖加载时,你的背景被覆盖 - 你可以使用一个覆盖 - 就像装在笔尖上的东西。一如既往地在莫尔 – Stuart