开发者

[comp setWeekday:(indexPath.row +2)]; is resetting last cell in section to row 0

开发者 https://www.devze.com 2023-03-30 11:21 出处:网络
I am putting dates of the year in to a uitableview (grouped style ) with each section being one week. Having 7 cells, 1 for each corresponding day of the week. I am adding 2 to indexpath.row because I

I am putting dates of the year in to a uitableview (grouped style ) with each section being one week. Having 7 cells, 1 for each corresponding day of the week. I am adding 2 to indexpath.row because I want the week to start on Monday. And cells are 0 based. The issue I am having is that it works all except for the last cell on 开发者_StackOverfloweach section is being treated as indexPath.row 0. Is there anyway to fix this issue?


I think it's because the last weekday value is set to 8 (row 6 + 2 = 8), whereas the Gregorian Calendar only allows values up until 7.

From the Apple docs:

Weekday units are the numbers 1 through n, where n is the number of days in the week. For example, in the Gregorian calendar, n is 7 and Sunday is represented by 1.

0

精彩评论

暂无评论...
验证码 换一张
取 消