Xamarin iOS tableview单元格扩展导致底部标题向上滑动

时间:2018-10-09 23:19:03

标签: c# xamarin xamarin.ios tableview

Gif of the Problem

public override async void RowSelected(UITableView tableView, NSIndexPath indexPath)
{

   tableView.DeselectRow(indexPath,true);
   var myCell = _cellDataDict[_cellSectionList[indexPath.Section]][indexPath.Row];

   myCell.IsSelected = !myCell.IsSelected;

   if( _previousCell != null && _previousCell != myCell)
       _previousCell.IsSelected = false;


   tableView.BeginUpdates();
   tableView.EndUpdates();

   tableView.ScrollToRow(indexPath, UITableViewScrollPosition.Top, true);
}


public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
   var myCell = _cellDataDict[_cellSectionList[indexPath.Section]][indexPath.Row];

   if(myCell.IsSelected)
       return 293.0f;
   else
       return 68.0f;
}

public override nfloat GetHeightForHeader(UITableView tableView, nint section)
{
    return 44.0f;
}

public override nfloat EstimatedHeightForHeader(UITableView tableView, nint section)
{
    return 44.0f;
}

public override nfloat EstimatedHeight(UITableView tableView, NSIndexPath indexPath)
{
   var myCell = _cellDataDict[_cellSectionList[indexPath.Section]][indexPath.Row];

   if(myCell.IsSelected)
       return 293.0f;
   else
       return 68.0f;
}

基本上,我想扩展表格视图单元格,然后在展开后滚动到表格视图的顶部。但是现在的动画看起来很奇怪,我想使其平滑。即使已经有副本,底部标题的顶部看起来仍会向上滑动。

0 个答案:

没有答案