C# 在代码中创建UITableView工件时
我使用以下代码创建UITableView:C# 在代码中创建UITableView工件时,c#,ios,uitableview,xamarin.ios,C#,Ios,Uitableview,Xamarin.ios,我使用以下代码创建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 VideoLibraryTabl
// 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有一个可视工件:
行高度是用
public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
{
return tableView.RowHeight * 2.0f;
}
如何去除表格单元格上的多余行
编辑:问题在于我定义了从UITableViewController而不是UIViewController继承的容器控制器。使用原始问题中的代码,这个问题就不明显了。我看到唯一的问题是调用[tableView sizeToFit]。通常不会在tableview上调用它,我只能想象这会影响给定UITableViewCell的渲染。此外,MonoTouch.Dialog是da bomb.com,它甚至还有一个称为QuickDialog的obj-C端口: 谢谢
Anuj我看到唯一一个关闭的是调用[tableView sizeToFit]。通常不会在tableview上调用它,我只能想象这会影响给定UITableViewCell的渲染。此外,MonoTouch.Dialog是da bomb.com,它甚至还有一个称为QuickDialog的obj-C端口: 谢谢
Anuj只需将tableView的行高乘以2,不要覆盖GetHeightForRow()。对于您的情况,它是一个常量,所以您不需要它
tableView.RowHeight *= 2;
只需将tableView的行高乘以2,不要覆盖GetHeightForRow()。对于您的情况,它是一个常量,所以您不需要它
tableView.RowHeight *= 2;
问题是我将容器控制器定义为继承自
UITableViewController
,而不是UIViewController
。有了原始问题中的代码,这个问题就不明显了 问题在于,我定义了从UITableViewController
继承的容器控制器,而不是UIViewController
。有了原始问题中的代码,这个问题就不明显了 如果你做了很多(甚至很少)表,我建议你看看MonoTouch.Dialog(),因为它会大大简化你的生活(或至少简化你的代码)。如果你做了很多(甚至很少)表,我建议你看看MonoTouch.Dialog(),因为它会大大简化你的生活(或至少简化你的代码)。