UITableView剪切我的表格视图,无法查看整个表格视图[Xamarin,iOS]

UITableView剪切我的表格视图,无法查看整个表格视图[Xamarin,iOS],uitableview,scroll,xamarin,xamarin.ios,Uitableview,Scroll,Xamarin,Xamarin.ios,我试图创建一个高度很大的自定义TableView,但是当我运行它时,我只能访问表中5行中的2行(在我提供的示例中) 以下是我如何查看表格的屏幕截图: 以下是指向我的表格源的链接: 这是我的视图控制器: unclass[] lol= new unclass[amount]; for (nint i = 0; i < amount; i++) { lol [i] = new unclass (); Console.WriteLine ("item

我试图创建一个高度很大的自定义TableView,但是当我运行它时,我只能访问表中5行中的2行(在我提供的示例中) 以下是我如何查看表格的屏幕截图: 以下是指向我的表格源的链接:

这是我的视图控制器:

    unclass[] lol= new unclass[amount];
    for (nint i = 0; i < amount; i++) {
        lol [i] = new unclass ();
        Console.WriteLine ("item created");
    }

    UITableView _table;
    _table  = new UITableView{ Frame = new CoreGraphics.CGRect (0, 30, View.Bounds.Width, 3000),Source= new TableSource(lol) };
    _table.SeparatorStyle = UITableViewCellSeparatorStyle.None;

    for (nint i = 0; i < amount; i++) {
        lol [i].imager =  await this.LoadImage (links[i]); //loads image from the net to table
    }
    View.AddSubview (_table);
}
unclass[]lol=新的unclass[金额];
对于(第九个i=0;i

我真的不明白为什么会发生这种情况

您的表源不是问题所在,我用一个空白表测试了它

正如Jason所说,您需要将表格的框架高度更改为“View.Bounds.height-30”-30,以补偿您的Y位置。我在下面创建了一个简单的示例,显示了所有5个单元格。因此,这可能是添加表的方式,或者如果viewController中有其他内容,也可能是这样。您是否能够发布更多视图控制器的代码

using UIKit;
using CoreGraphics;
using System;
using Foundation;

namespace SO_Xam_actvity
{
    public class bigTableViewController : UIViewController
    {
        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            UITableView _table;
            _table  = new UITableView{ Frame = new CGRect (0, 30, View.Bounds.Width, View.Bounds.Height-30),Source= new TableSource(new [] {1,1,1,1,1}) };
            _table.SeparatorStyle = UITableViewCellSeparatorStyle.None;
            View.AddSubview (_table);
        }
    }

    public class TableSource : UITableViewSource
    {
        int[] tableItems;
        string cellIdentifier = bigTableViewCell.Key;

        public TableSource (int[] items)
        {
            tableItems = items;
        }

        public override nint RowsInSection (UITableView tableview, nint section)
        {
            return tableItems.Length;
        }

        public override nfloat GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
        {
            return 200;
        }
        public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell (cellIdentifier) as bigTableViewCell;
            if (cell == null) {
                cell = new bigTableViewCell();
            }
            cell.DetailTextLabel.Text = $"{indexPath.Row}";
            return cell;

        }
    }


    public class bigTableViewCell : UITableViewCell
    {
        public static readonly NSString Key = new NSString ("bigTableViewCell");

        public bigTableViewCell () : base (UITableViewCellStyle.Value1, Key)
        {
            TextLabel.Text = "TextLabel";
        }
    }
}

请不要发布场外代码列表的链接。花点时间在你的帖子中直接包含相关的代码。问题是我不明白为什么我会得到我得到的结果,这就是为什么我会包含我的整个表源代码。你仍然应该内联发布代码,而不是链接到外部站点。您正在将表的高度设置为3000-请尝试将其设置为屏幕边界。很抱歉,我将在下次的行中发布我的代码。我将3000改为“View.Bounds.Height”,而不是只显示2,现在显示2和1/3,但仍然没有显示5。所以你的问题本质上是“为什么我的TableView不滚动?”在So和其他网站上有数百个点击“TableView不滚动”。你读过这些书吗?