Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在代码中创建UITableView工件时_C#_Ios_Uitableview_Xamarin.ios - Fatal编程技术网

C# 在代码中创建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

我使用以下代码创建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有一个可视工件:

行高度是用

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(),因为它会大大简化你的生活(或至少简化你的代码)。