I have a UITableView where I want to hide the header of the first row, unless the user scrolls up ward, then it can be present.
My current approach is the following:
Table.ContentInset = new UIEdgeInsets(-30, 0, 0, 0);
Table.ScrolledToTop += (sender, e) => {
Table.ContentInset = new UIEdgeInsets(0, 0, 0, 0);
};
But this does not work as expected. Thanks for any help.
You can use this method:
tableView.ScrollToRow (Foundation.NSIndexPath.FromItemSection (0, 0), UITableViewScrollPosition.Top, false);
This is the complete code:
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);
Hope it can help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.