简体   繁体   English

GetViewForHeader可在模拟器中工作,但不能在设备上工作

[英]GetViewForHeader works in the simulator but not working on the device

So i have a GetViewForHeader override and it works great in the simulator. 所以我有一个GetViewForHeader重写,它在模拟器中很好用。 When I debug the app on the device (both iPad and iPhone) no styling is applied. 当我在设备(iPad和iPhone)上调试应用程序时,未应用任何样式。 There is no error and the GetViewForHeader code is definitely NOT being run. 没有错误,并且绝对不会运行GetViewForHeader代码。 TitleForHeader etc is tho. TitleForHeader等是。 Odd! 奇!

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

The GetViewForHeader method is only called if GetHeightForHeader returns a non-zero integer, so ensure you are implementing the GetHeightForHeader method and returning an appropriate height. 仅当GetHeightForHeader返回非零整数时才调用GetViewForHeader方法,因此请确保您正在实现GetHeightForHeader方法并返回适当的高度。

It's also worth noting that the TitleForHeader method should not be implemented if using header views. 还值得注意的是,如果使用标题视图,则不应实现TitleForHeader方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Monotouch应用程序在设备中崩溃,但在模拟器中工作正常 - Monotouch application is getting crashed in device but works fine in simulator Xamarin.ios 不适用于真正的 iOS 设备,但它适用于模拟器 - Xamarin.ios does NOT work on real iOS device but it works on Simulator 应用程序在模拟器中工作正常,但在设备上引发NSUnknownKeyException异常 - App works fine in simulator but throws NSUnknownKeyException exception on device Xamarin 中的可移植类库在 iOS 模拟器上工作但不在设备上 - Portable Class Library in Xamarin working on iOS Simulator but not on device 自定义 WebView 在模拟器中工作,但不在物理设备中。 Xamarin - Custom WebView working in simulator but not in physical device. Xamarin 在设备上运行时,MonoTouch不支持OpenAsync方法打开Web服务连接(在模拟器上工作) - MonoTouch does not support OpenAsync method for opening a web service connection when running on the device (works on the simulator) SignalR .Net客户端在设备上出现500服务器错误,在模拟器上工作正常 - SignalR .Net Client fails with 500 server error on device, on simulator works fine 在设备上运行时,MonoTouch 4.2不支持System.ServiceModel.EndpointAddress()(在模拟器上运行) - MonoTouch 4.2 does not support System.ServiceModel.EndpointAddress() when running on the device (works on the simulator) MonoTouch iOS应用程序无法在设备目录中找到文件-在模拟器上工作 - MonoTouch iOS application can't find files in directory on device - works on simulator unity3d-无法在设备上显示Facebook个人资料图像(模拟器运行完美) - unity3d - can't show facebook profile image on the device ( simulator works perfect )
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM