1

我陷入了一个困境。我创建了一个表格,但无法滚动到最后几行。我可以尝试通过拖动来强制表格滚动到底部,但这当然不是可取的。有没有其他人看到这个问题的解决方案?

public partial class Table : UIViewController
    {
    public static UITableView table;
    public TableItem[] tableItems;
    public TableSource tableSource;

    public Table () : base ("Table", null)
    {
    }

    public override void DidReceiveMemoryWarning ()
    {
        // Releases the view if it doesn't have a superview.
        base.DidReceiveMemoryWarning ();

        // Release any cached data, images, etc that aren't in use.
    }

    public override void ViewDidLoad ()
    {
        base.ViewDidLoad ();
        table = new UITableView (View.Bounds);
        table.BackgroundColor = UIColor.Clear;
        //this.View.BackgroundColor = UIColor.Black;
        //UIImageView imgView = new UIImageView(UIImage.FromFile("bg_start.png"));
        //this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("../Images/BusinessEntityLogos/bg_start.png"));
        this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("Images/bg_start.png"));
        //table.Bounds = new RectangleF (300, 300, 600, 500);

        tableItems = new TableItem[10];
        tableItems [0] = new TableItem ("Scuba", "Steve", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [1] = new TableItem ("George", "Jackson", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [2] = new TableItem ("Steve", "Martin", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [3] = new TableItem ("Thisa", "Myname", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [4] = new TableItem ("Steve", "Carell", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [5] = new TableItem ("Scuba", "Steve", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [6] = new TableItem ("George", "Jackson", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [7] = new TableItem ("Steve", "Martin", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [8] = new TableItem ("Thisa", "Myname", "47409", "11/09/2013", "Bloomington", "Disposition");
        tableItems [9] = new TableItem ("Steve", "Carell", "47409", "11/09/2013", "Bloomington", "Disposition");

        tableSource = new TableSource (tableItems);
        table.Source = tableSource;
        Add (table);
        // Perform any additional setup after loading the view, typically from a nib.
    }

    public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
    {
        // Return true for supported orientations
        return false;
    }

    public static void reloadData()
    {
        table.ReloadData ();
    }
}









public class TableSource : UITableViewSource {

    static public string DbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "AMA.db");
    static protected string connectionString = "Data Source=" + DbPath;
    protected SqliteConnection conn;

    TableItem[] tableItems;
    NSString cellIdentifier = new NSString("CustomCell");
    public int rows;
    public UITableView mainView;
    public int sectionCurrent;

    public TableSource (TableItem[] items)
    {
        tableItems = items;
        rows = 0;
    }
    public override int RowsInSection (UITableView tableview, int section)
    {
        mainView = tableview;
        sectionCurrent = section;
        if(rows != tableItems.Length)
        rows += 40;
        return rows;
    }
    public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
    {
        CustomCell cell = tableView.DequeueReusableCell (cellIdentifier) as CustomCell;
        if (cell == null)
            cell = new CustomCell (cellIdentifier);
        cell.UpdateCell (tableItems[indexPath.Row].firstName
                         , tableItems [indexPath.Row].lastName
                         , tableItems [indexPath.Row].zipCode
                         , tableItems [indexPath.Row].dateTime
                         , tableItems [indexPath.Row].location
                         , tableItems [indexPath.Row].disposition
                         );

        cell.SelectionStyle = UITableViewCellSelectionStyle.None;

        return cell;
    }


    public override float GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
    {
        return 140f;
    }

    public override UIView GetViewForFooter (UITableView tableView, int section)
    {
        return new FooterView ();
    }

    public override string TitleForHeader (UITableView tableView, int section)
    {
        return "Meetings";
    }
}
4

0 回答 0