How to use custom UITableViewCell from Interface Builder?

后端 未结 3 1814
耶瑟儿~
耶瑟儿~ 2021-01-13 06:11

I want to be able to design my own UITableViewCell in IB. But I keep getting a null ref exception when trying to access the label I defined in IB.

Here\'s what I\'m

3条回答
  •  清酒与你
    2021-01-13 06:39

    Check this link. This is a very interesting article for creating a custom TableViewCell. I think the error is due to the asynchronous loading of the xib provided by Monotouch.

    You have to provide your own costructor like this:

    public TestCellView(string sKey) //: base(UITableViewCellStyle.Default, sKey)
    {
        MonoTouch.Foundation.NSBundle.MainBundle.LoadNib ("YOUR NIBNAME", this, null);
    }
    

    Hope this helps!

提交回复
热议问题