Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

UIImageView returns null instance from Storyboard

ArvisArvis USMember ✭✭
edited June 2014 in Xamarin.iOS

Made custom UITableViewCell class using storyboard designer. It successfully generated partial class:

                   [Register ("VehiclesTableCell")]
                   partial class VehiclesTableCell
                        [GeneratedCode ("iOS Designer", "1.0")]
                        MonoTouch.UIKit.UIImageView troImageView { get; set; }

                        void ReleaseDesignerOutlets ()
                            if (troImageView != null) {
                                troImageView.Dispose ();
                                troImageView = null;

when running app ImageView always has null reference, so i cant use that property in code:

    partial class VehiclesTableCell : UITableViewCell
        public VehiclesTableCell(IntPtr handle)
            : base(handle) {

        public void UpdateCell(UIImage troImage) {
            troImageView.Image = troImage;  // null reference exception troImageView

Does storyboard not suppose to instantiate all of its subviews automatically?


  • ArvisArvis USMember ✭✭

    Post images from involved classes: TableViewController, TableSource and TableViewCell.

  • JacobSlusserJacobSlusser USMember ✭✭


    I'm having the same issue. Did you find a solution?


  • ArvisArvis USMember ✭✭

    @JacobSlusser‌ , actually i did.
    Let me remember what i did :)

  • ArvisArvis USMember ✭✭
    edited August 2014

    I used new cell reuse pattern mentioned in: in "Cell Reuse in iOS 6" part with new cell register method: TableView.RegisterClassForCellReuse (typeof(MyCell), MyCellId);

    But this pattern actually returns not properly instantiated cell items (all of them is null), so i just remove that cell reuse registration method from my controller. Because when using Storyboard with custom cell, it always return cell (not null) even if it not exist. So there is no need to check for null either in overridden GetCell method in TableViewSource class.

    So this is some kind of MonoTouch bug.

Sign In or Register to comment.