I am developing an Rubymotion app. In this app I got a tableview with 10 rows. I want to group these rows by the created_at and display each grouped date in section titles.

It works fine to show these titles but the problem is that all 10 rows appear in under each section title causing there to be 30 rows (3 sections). In other words all 10 rows appears in all sections. What is wrong?

These are my delegates:

def numberOfSectionsInTableView(tableView)

    @tasks.length

  end

  def tableView(tableView, numberOfRowsInSection:section)

    @tasks.length

  end

  def tableView(tableView, titleForHeaderInSection:section)

    @tasks[section]['start_date']

  end
有帮助吗?

解决方案

In tableView(tableView, numberOfRowsInSection:section) you must return the actual number of tasks for that section, not the count of all tasks. So @tasks[section].length.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top