我想将自定义视图 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;
}
当我运行应用程序时它崩溃了,没有看到任何错误。