如何确定iOS的第一周工作日?

时间:2022-10-21 10:34:39

I am using Tapku's calendar in my application and I want to determine if the week should start on a Sunday or a Monday depending on the user's settings. I am calling firstWeekday, but for some reason it returns 1 (Sunday) on a device where the built-in calendar starts the weeks on Mondays (and hence it should return 2):

我在我的应用程序中使用Tapku的日历,我想确定一周应该在周日或周一开始,具体取决于用户的设置。我打电话给第一周,但由于某种原因,它会在一个设备上返回1(星期日),其中内置日历在星期一开始几周(因此它应该返回2):

NSCalendar* cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[cal firstWeekday];

Any suggestions as to what I might be missing?

关于我可能缺少什么的任何建议?

2 个解决方案

#1


17  

Ok, so it turns out this is the correct way of doing it:

好的,事实证明这是正确的做法:

[[NSCalendar currentCalendar] firstWeekday]

#2


-6  

How to change the default start day of the week in the iPhone and iPad calendar Launch the Settings app on your iPhone or iPad. Scroll down and tap on Mail, Contacts, Calendars. Under the Calendars section, tap on Start Week On. Here you can change the day of the week your calendar starts on.

如何在iPhone和iPad日历中更改一周的默认开始日期在iPhone或iPad上启动“设置”应用程序。向下滚动并点按“邮件”,“通讯录”,“日历”。在“日历”部分下,点按“开始周开”。在这里,您可以更改日历开始的星期几。

#1


17  

Ok, so it turns out this is the correct way of doing it:

好的,事实证明这是正确的做法:

[[NSCalendar currentCalendar] firstWeekday]

#2


-6  

How to change the default start day of the week in the iPhone and iPad calendar Launch the Settings app on your iPhone or iPad. Scroll down and tap on Mail, Contacts, Calendars. Under the Calendars section, tap on Start Week On. Here you can change the day of the week your calendar starts on.

如何在iPhone和iPad日历中更改一周的默认开始日期在iPhone或iPad上启动“设置”应用程序。向下滚动并点按“邮件”,“通讯录”,“日历”。在“日历”部分下,点按“开始周开”。在这里,您可以更改日历开始的星期几。