gpt4 book ai didi

c# - 在代码中创建时的 UITableView 工件

转载 作者:行者123 更新时间:2023-11-28 20:42:43 29 4
gpt4 key购买 nike

我使用以下代码在代码中创建了一个 UITableView:

// no xib
tableView = new UITableView(
new RectangleF(0,0, this.View.Frame.Width, this.View.Frame.Height),
UITableViewStyle.Grouped);
tableView.Delegate = new VideoLibraryTVDelegate();
tableView.DataSource = new VideoLibraryTableViewDataSource(this);
tableView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth |
UIViewAutoresizing.FlexibleHeight;
tableView.BackgroundColor = UIColor.FromPatternImage(this.backgroundImage);
tableView.SeparatorStyle = UITableViewCellSeparatorStyle.SingleLine;

tableView.SizeToFit ();
tableView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height);
this.View.AddSubview(tableView);

生成的 UITableView 具有视觉效果:

enter image description here

行高完成

public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
{
return tableView.RowHeight * 2.0f;
}

如何去掉表格单元格上的多余线条?

编辑:原来问题是我将容器 Controller 定义为继承自 UITableViewController 而不是 UIViewController。使用原始问题中的代码,这个问题不会很明显。

最佳答案

只需将 tableView 的 RowHeight 乘以 2,不要覆盖 GetHeightForRow()。对于您的情况,它是一个常数值,因此您不需要它。

tableView.RowHeight *= 2;

关于c# - 在代码中创建时的 UITableView 工件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7787984/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com