V
V
Vyacheslav Zolotov2016-02-14 15:32:02
iOS
Vyacheslav Zolotov, 2016-02-14 15:32:02

What is the error when creating a custom cell in UICollectionView?

Here collectionView.DequeueReusableCell("identity", indexPath) as ImageCell the result is always null, but if you cast it to the UICollectionViewCell type, everything is fine and the cell is located. What could be the problem?
ImageCell implementation:

public class ImageCell : UICollectionViewCell
    {
        UIImageView imageView;

        [Export("initWithFrame:")]
        public ImageCell(System.Drawing.RectangleF frame) : base(frame)
        {
            BackgroundView = new UIView { BackgroundColor = UIColor.Orange };

            SelectedBackgroundView = new UIView { BackgroundColor = UIColor.Green };

            ContentView.Layer.BorderColor = UIColor.LightGray.CGColor;
            ContentView.Layer.BorderWidth = 2.0f;
            ContentView.BackgroundColor = UIColor.White;
            ContentView.Transform = CGAffineTransform.MakeScale(0.8f, 0.8f);

            imageView = new UIImageView(UIImage.FromBundle("placeholder.png"));
            imageView.Center = ContentView.Center;
            imageView.Transform = CGAffineTransform.MakeScale(0.7f, 0.7f);

            ContentView.AddSubview(imageView);
        }

        public UIImage Image
        {
            set
            {
                imageView.Image = value;
            }
        }
    }

Спасибо.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question