2016-09-03 10 views
0

私は、ユーザーがワードをスクロールしない限り、最初の行のヘッダーを非表示にするUITableViewを持っています。ビューの読み込み時にUITableViewのスクロール位置を設定する方法は?

私の現在のアプローチは以下の通りです:

Table.ContentInset = new UIEdgeInsets(-30, 0, 0, 0); 
Table.ScrolledToTop += (sender, e) => { 
     Table.ContentInset = new UIEdgeInsets(0, 0, 0, 0); 

}; 

しかし、予想通り、これは動作しません。助けてくれてありがとう。これは完全なコードである

tableView.ScrollToRow (Foundation.NSIndexPath.FromItemSection (0, 0), UITableViewScrollPosition.Top, false); 

答えて

1

あなたは、このメソッドを使用することができます

tableView = new UITableView (UIScreen.MainScreen.Bounds); 
      this.View.AddSubview (tableView); 

      UILabel header = new UILabel (new CGRect (0, 0, tableView.Frame.Width, 50)){BackgroundColor = UIColor.Blue}; 
      header.Text = "I'm header"; 
      header.TextColor = UIColor.White; 
      header.TextAlignment = UITextAlignment.Center; 
      tableView.TableHeaderView = header; 

      TableViewSource mySource = new TableViewSource(); 
      tableView.Source = mySource; 
      tableView.ReloadData(); 

      tableView.ScrollToRow (Foundation.NSIndexPath.FromItemSection (0, 0), UITableViewScrollPosition.Top, false); 

は、それはあなたを助けることができると思います。

関連する問題