문제

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