0

I would like to add a custom view XIB to my UITable views header. Following this link How to add a custom view to a XIB file defined view in monotouch i created a XIB with a view. It has just two labels in it. I then have a cs file. Called XIB as mention in the link

public override UIView GetViewForHeader(UITableView tableView, int sectionIndex) {


  var myHeader = new UIView(); 


  var views = NSBundle.MainBundle.LoadNib("CustomHeaderView", this, null); 
  CustomHeaderView loginView = Runtime.GetNSObject(views.ValueAt(0)) as CustomHeaderView;
  loginView.UpdateWithData("test","test");
  myHeader.AddSubview(loginView);
  return myHeader;
}

When i run the app it is crashing, dont see any error.

Community
  • 1
  • 1
User382
  • 864
  • 19
  • 42

1 Answers1

0

Make sure that your .XIB is not using AutoLayout and you are using an older iOS. The AutoLayout is new for 6.x and will cause a crash on the 5.x based devices. I see this quite often.

Eric
  • 462
  • 1
  • 5
  • 13