2014-02-19 31 views
0

我正在开发一个Rubymotion应用程序。 在这个应用程序中,我得到了10行的tableview。我想通过created_at将这些行分组 ,并在章节标题中显示每个分组日期。所有行重复自己在每个部分标题下

它可以很好地显示这些标题,但问题是所有10行出现在每个节标题下,导致有30行(3节)。换句话说,所有10行都出现在所有部分中。哪里不对?

这是我代表:

def numberOfSectionsInTableView(tableView) 

    @tasks.length 

    end 

    def tableView(tableView, numberOfRowsInSection:section) 

    @tasks.length 

    end 

    def tableView(tableView, titleForHeaderInSection:section) 

    @tasks[section]['start_date'] 

    end 

回答

3

tableView(tableView, numberOfRowsInSection:section)您必须返回任务的实际数量为节中,并不是所有的任务数。所以@tasks[section].length

相关问题