1
所以我有一个GetViewForHeader覆盖,它在模拟器中工作得很好。当我调试设备上的应用程序(包括iPad和iPhone)时,不会应用样式。没有错误,GetViewForHeader代码肯定不会运行。 TitleForHeader等是tho。奇!GetViewForHeader在模拟器中工作,但不在设备上工作
public override string TitleForHeader (UITableView tableView, int section)
{
return tableItems[section].Name;
}
public override UIView GetViewForHeader(UITableView tableView, int section)
{
// THIS DOES NOT FIRE ON THE DEVICE - BUT IT DOES ON THE SIMULATOR
return BuildSectionHeaderView(tableItems[section].Name);
}
public static UIView BuildSectionHeaderView(string caption) {
UIView view = new UIView(new System.Drawing.RectangleF(0,0,320,20));
view.BackgroundColor = UIColor.White;
UILabel label = new UILabel();
label.Opaque = false;
label.TextColor = UIColor.FromRGB (190, 0, 0);
label.Font = UIFont.FromName("Helvetica-Bold", 16f);
label.Frame = new System.Drawing.RectangleF(5,10,315,20);
label.Text = caption;
view.AddSubview(label);
return view;
}
我现在编辑了代码 - 删除了TiteForHeader并添加了GetHeightForHeader。我现在得到一个不同的错误:类型'MonoTouch.Foundation.You_Should_Not_Call_base_In_This_Method'的异常被抛出。 –
错误是来自同一地点还是来自另一个文件?我猜测没有看到更多的代码,但我可以建议的是,你确定你确实在你的'GetHeightForHeader'方法中使用'override'关键字。否则,解决这些问题很可能会暴露另一个问题。 –