1

Xamarin と MvvmCross で構築された iPhone アプリ内で MvxCollectionViewCell の背景画像を表示しようとしています。iOS 6.0 以降をターゲットにしています。以下は私が使用しているコードです。背景画像を表示するのに少し苦労しています。私は自分が間違っていることを理解できないようです。それはかなり簡単に進むべきだと思われます。XCodeでセルを作成しました。セルは 100 X 100 です。これには、90 X 72 の単一の UIImageView が含まれています。UIImageView の X と Y は、それぞれ 5 と 8 です。セル内で画像のサイズを変更するのにも問題がありますが、近いうちに別の質問を投稿する予定です。

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];
    }
  }
 }

助けてくれてありがとう!

4

1 に答える 1