0

我想将自定义视图 XIB 添加到我的 UITable 视图标题中。按照这个链接如何在monotouch中将自定义视图添加到XIB文件定义的视图中, 我创建了一个带有视图的XIB。它只有两个标签。然后我有一个cs文件。链接中提到的称为 XIB

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

当我运行应用程序时它崩溃了,没有看到任何错误。

4

1 回答 1

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.

于 2013-04-26T21:14:29.097 回答