2012-04-18 61 views
1

我制作了一个TableDataSource,它使用了我的自定义TableCell和两个按钮。UITableView拥有比DataSource更多的元素

 List<ConductedActivitiesItem> _items = new List<ConductedActivitiesItem>(); 
     foreach(var item in this._logicActivities.Steps) 
     { 
      _items.Add(new ConductedActivitiesItem(){ Date = "12-13", Text = item.Lines[0], Checked = null }); 
     } 

     var ds = new ConductedActivitiesDataSource(_items); 
     var dg = new CSTableViewDelegate(null); 

     dg.SelectionChanged += this.Steps_SelectionChanged; 

     this.Pad_tbvMeasures.DataSource = null; 

     this.Pad_tbvMeasures.DataSource = ds; 
     this.Pad_tbvMeasures.Delegate = dg; 
     this.Pad_tbvMeasures.ReloadData(); 

列表具有4项: 一个 b Ç d

表视图显示: 一个 b Ç d 一个 b Ç d 一个 b c d

有没有人有一个想法,为什么列表显示比DataSource更多的项目?

+0

您的RowsInSection()如何获取行数? – Jason 2012-04-18 14:05:27

+0

在我的DataSource中,我返回列表中的项目数 - > return this._list.Count – Alex 2012-04-18 14:13:25

+0

问题解决了......谢谢Jason你帮了我很多。我的同事也覆盖了NumberOfSections()并返回_items.Count。现在我删除了这个方法,它工作。 – Alex 2012-04-18 14:19:53

回答

3

检查您的NumberOfSections()和RowsInSetion()方法以验证它们是否返回了正确的值。

+0

通过删除NumberOfSections()来解决 – Alex 2012-04-18 14:22:46

相关问题