Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何以与一周中的月份和日期相匹配的方式在日历中以编程方式布局日期?_Objective C_Uitableview_Uicollectionview - Fatal编程技术网

Objective c 如何以与一周中的月份和日期相匹配的方式在日历中以编程方式布局日期?

Objective c 如何以与一周中的月份和日期相匹配的方式在日历中以编程方式布局日期?,objective-c,uitableview,uicollectionview,Objective C,Uitableview,Uicollectionview,我该怎么做 我相信这是以前做过的。我在github上检查了几个项目,比如calendar master,但它们都比我需要的复杂 2013年10月 S M T W T F S 30123456 78991011213 141617181920 2122232425627 28293031123 有没有最好的方法来做到这一点?以与该月的星期几相匹配的方式安排日期 这将在tableview中进行,但我不是在寻找代码,只是寻找其背后的逻辑。除非已经有一个很好的解决方案 谢谢大家! 逻辑可以是这样的(伪代

我该怎么做

我相信这是以前做过的。我在github上检查了几个项目,比如calendar master,但它们都比我需要的复杂

2013年10月

S M T W T F S

30123456

78991011213

141617181920

2122232425627

28293031123

有没有最好的方法来做到这一点?以与该月的星期几相匹配的方式安排日期

这将在tableview中进行,但我不是在寻找代码,只是寻找其背后的逻辑。除非已经有一个很好的解决方案


谢谢大家!

逻辑可以是这样的(伪代码):

get the weekday of the first day of the month in question
determine the number of days of the previous month
fill the first line 
   with leading final days of previous month, if any
   the remaining days for the first week of the month in question
fill all other lines
fill the rest of the last line 
   with the first days of the following month, if any space left