C# 触摸动画的TableView展开和折叠部分
我有一个已经填充了数据的列表,在触摸时,我希望该部分展开并删除上一个展开部分中的行。另外,在第0节中,我有一个不使用触摸识别的促销视图,这是导致C# 触摸动画的TableView展开和折叠部分,c#,ios,uitableview,xamarin,C#,Ios,Uitableview,Xamarin,我有一个已经填充了数据的列表,在触摸时,我希望该部分展开并删除上一个展开部分中的行。另外,在第0节中,我有一个不使用触摸识别的促销视图,这是导致 \u restaurantmodeldeailds.Menu.Regular[(int)section-\u isPromoView].Products.Count isPromoView的值为1 我尝试了不同的方法,我在这里公开的方法在第二次单击EndUpdates()时出现了以下问题,在第一次单击时什么也没有发生 NSInternalInconsi
\u restaurantmodeldeailds.Menu.Regular[(int)section-\u isPromoView].Products.Count
isPromoView的值为1
我尝试了不同的方法,我在这里公开的方法在第二次单击EndUpdates()时出现了以下问题,在第一次单击时什么也没有发生
NSInternalInconsistenceException原因:无效更新:第6节中的行数无效。更新后现有节中包含的行数(6)必须等于更新前该节中包含的行数(0),加上或减去从该节中插入或删除的行数(0插入,0删除),加上或减去移入或移出该节的行数(0移入,0移出)
这是触摸处理器
void SectionHeaderViewOpened( UITableView tableView, int section)
{
List indexPathsToInsert = new List( );
List indexPathsToDelete = new List();
for (int i = 0; i < tableView.NumberOfRowsInSection(section); i++)
{
indexPathsToInsert.Add(NSIndexPath.FromRowSection(i, section));
}
if(_sectionOpen != -1)
for (int i = 0; i < tableView.NumberOfRowsInSection(_sectionOpen); i++)
{
indexPathsToDelete.Add(NSIndexPath.FromRowSection(i, _sectionOpen));
}
UITableViewRowAnimation insertAnimation;
UITableViewRowAnimation deleteAnimation;
if ( _sectionOpen == -1 || section < _sectionOpen )
{
insertAnimation = UITableViewRowAnimation.Top;
deleteAnimation = UITableViewRowAnimation.Bottom;
}
else
{
insertAnimation = UITableViewRowAnimation.Bottom;
deleteAnimation = UITableViewRowAnimation.Top;
}
//tableView.reloadData();
tableView.BeginUpdates();
tableView.DeleteRows(indexPathsToDelete.ToArray(), deleteAnimation);
tableView.InsertRows(indexPathsToInsert.ToArray(), insertAnimation);
tableView.EndUpdates( );
_sectionOpen = section;
}
public override UITableViewCell GetCell( UITableView tableView, NSIndexPath indexPath )
{
RestaurantRow cell;
var product = _restaurantModelDetails.Menu.Regular[indexPath.Section - _isPromoView].Products[indexPath.Row];
cell = (RestaurantRow)tableView.DequeueReusableCell(CellIdentifier) ?? new RestaurantRow(product.Name);
return cell;
}
public override nint RowsInSection( UITableView tableView, nint section )
{
//Resturn number of products
if ( section == _sectionOpen )
{
return _restaurantModelDetails.Menu.Regular[(int)section - _isPromoView].Products.Count;
}
return 0;
}
void section头服务打开(UITableView tableView,int section)
{
List indexPathsToInsert=新列表();
List indexPathsToDelete=新列表();
对于(int i=0;i
我发现了我遇到的问题
我正在从中获取我的行数
tableView.NumberOfRowsInSection(section)
_restaurantModelDetails.Menu.Regular[section - _isPromoView].Products.Count
结果是0
解决方法是从中获取行
tableView.NumberOfRowsInSection(section)
_restaurantModelDetails.Menu.Regular[section - _isPromoView].Products.Count
@Schemetrical,即C#,这里的约定是PascalCase。@CMircea没有意识到这是Xamarin。